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

Tapani tapani.palli at intel.com
Tue Mar 24 23:21:13 PDT 2015


I don't quite agree with this change, IMO the behavior is fine as it 
matches how other backends work. The 'gl' prefix is "internal detail", 
user should not be trying to dlopen some other functions anyway?

On 03/24/2015 05:56 PM, Emil Velikov wrote:
> ... 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;
>   }



More information about the waffle mailing list