[PATCH] fix agent/findkey.c

NIIBE Yutaka gniibe at fsij.org
Thu Nov 1 01:17:22 CET 2012


On 2012-10-31 at 14:17 +0100, Werner Koch wrote:
> On Wed, 31 Oct 2012 08:09, gniibe at fsij.org said:
> > -      args[argidx++] = (void *)uri_length;
> > -      args[argidx++] = (void *)uri;
> > +      args[argidx++] = (void *)&uri_length;
> > +      args[argidx++] = (void *)&uri;
> 
> I would say, this is the correct fix:
> 
> +      args[argidx++] = (void *)((int)uri_length);
> +      args[argidx++] = (void *)uri;
> 
> The format string ("%b") expect an /int/ and an /const char */:
> 
> 	  else if (*p == 'b')
> 	    {
> 	      /* Insert a memory buffer.  */
> 	      const char *astr;
> 	      int alen;
> 
> 	      ARG_NEXT (alen, int);
> 	      ARG_NEXT (astr, const char *);

Please note that the call in this case is gcry_sexp_build_array, with
void **arg_list.

In libgcrypt/src/sexp.c, ARG_NEXT is implemented as:

1009   /* Depending on whether ARG_LIST is non-zero or not, this macro gives
1010      us the next argument, either from the variable argument list as
1011      specified by ARG_PTR or from the argument array ARG_LIST.  */
1012 #define ARG_NEXT(storage, type)                          \
1013   do                                                     \
1014     {                                                    \
1015       if (!arg_list)                                     \
1016         storage = va_arg (arg_ptr, type);                \
1017       else                                               \
1018         storage = *((type *) (arg_list[arg_counter++])); \
1019     }                                                    \
1020   while (0)

Here (line 1018), it expects a _pointer_ to the type and it is
_dereferenced_.
-- 





More information about the Gnupg-devel mailing list