When possible, please submit patches and requests for review via GitHub
as a pull request.   This will ensure the patch is not lost and provides
the ability to apply comments both on the pull request as well as
comment inline to the patch.

The patch will be tested by the Continuous Integration system and the
results posted back to the conversation.

Thanks.


On 10/26/2017 8:44 AM, Harald Barth wrote:
> 
> I may have not yet shared my final version of the patch which gives
> the user as much error message(s) that are extractable from both the
> context and the return code:
> 
> $ diff -u error_string.c.orig error_string.c
> --- error_string.c.orig 2017-07-11 07:14:16.000000000 +0200
> +++ error_string.c      2017-10-05 21:04:50.064079947 +0200
> @@ -234,8 +234,6 @@
>          }
>         HEIMDAL_MUTEX_unlock(&context->mutex);
>  
> -        if (str)
> -            return str;
>      }
>      else
>      {
> @@ -249,10 +247,26 @@
>      if (free_context)
>          krb5_free_context(context);
>  
> -    if (cstr)
> -        return strdup(cstr);
> +    if (!cstr) {
> +       if (cstr = error_message(code)) {
> +           strlcpy(buf, cstr, sizeof(buf));
> +           cstr = buf;
> +       }
> +    }
>  
> -    cstr = error_message(code);
> +    if (str && !cstr)
> +       return str;
> +
> +    if (str && cstr) {
> +       if (strncmp(str, cstr, sizeof(buf)) == 0)
> +           return str;
> +       else {
> +           strlcat(buf, ", ", sizeof(buf));
> +           strlcat(buf,  str, sizeof(buf));
> +           return strdup(cstr);
> +       }
> +    }
> +
>      if (cstr)
>          return strdup(cstr);
>  
> So...whatyouthinkaboutthat? Yes, str*foo() in C is a pain.
> 
> Harald.
> 

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to