[waffle] [PATCH 05/10] nacl: emit errors when things fail

Emil Velikov emil.l.velikov at gmail.com
Tue Mar 24 08:56:21 PDT 2015


... rather than being silent. Changes are very small that either of
these two cases will be hit, although if/when they are it's better to
provide some information to the user.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/waffle/nacl/nacl_dl.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/waffle/nacl/nacl_dl.c b/src/waffle/nacl/nacl_dl.c
index 63e3aaf..b882387 100644
--- a/src/waffle/nacl/nacl_dl.c
+++ b/src/waffle/nacl/nacl_dl.c
@@ -99,8 +99,11 @@ nacl_dl_can_open(struct wcore_platform *wc_plat,
 static char *
 nacl_dl_prefix(const char *src, const char *prefix)
 {
-    if (strncmp(src, "gl", 2) != 0)
+    if (strncmp(src, "gl", 2) != 0) {
+        wcore_errorf(WAFFLE_ERROR_UNKNOWN,
+                     "NACL symbol name does not start with \"gl\"");
         return NULL;
+    }
 
     uint32_t len = strlen(src) + strlen(prefix);
 
@@ -108,7 +111,13 @@ nacl_dl_prefix(const char *src, const char *prefix)
     if (!dst)
         return NULL;
 
-    snprintf(dst, len, "%s%s", prefix, src + 2);
+    int n = snprintf(dst, len, "%s%s", prefix, src + 2);
+    if (n < 0 || n >= len) {
+        wcore_errorf(WAFFLE_ERROR_UNKNOWN,
+                     "NACL cannot create symbol prefix");
+        free(dst);
+        return NULL;
+    }
 
     return dst;
 }
-- 
2.3.1



More information about the waffle mailing list