Am Sonntag, 30. April 2006 11:04 schrieb Nils Larsch:
> > --- src/pkcs11/framework-pkcs15.c (revision 2919)
> > +++ src/pkcs11/framework-pkcs15.c (working copy)
> > @@ -2345,6 +2345,7 @@
> > sc_debug(context, "data_len %i\n", data->data_len);
> > check_attribute_buffer(attr, data->data_len);
> > memcpy(attr->pValue, data->data, data->data_len);
> > + free(data);
> > }
> > break;
> > default:
>
> don't know
data is malloc'ed, no reference is kept as far as I can see,
so we need to free it.
> > @@ -758,10 +758,14 @@
> > SC_PKCS15_AODF, NULL);
> > }
> >
> > - if (r >= 0)
> > + if (r >= 0) {
> > r = sc_pkcs15init_update_dir(p15spec, profile, app);
> > - if (r >= 0)
> > - r = sc_pkcs15init_update_tokeninfo(p15spec, profile);
> > +
> > + if (r >= 0)
> > + r = sc_pkcs15init_update_tokeninfo(p15spec, profile);
> > + } else {
> > + free(app); /* unused */
> > + }
>
> hmm, if sc_pkcs15init_update_dir() fails we still have a possible memory
> leak (unfortunately it's not clear whether we need to free app or not when
> sc_pkcs15init_update() returns an error)
right. so the fix is incomplete, but still fixes a part of the problem.
commit this fix and open a bug for the remaining hole?
> > --- src/libopensc/apdu.c (revision 2919)
> > +++ src/libopensc/apdu.c (working copy)
> > @@ -222,14 +222,15 @@
> > }
> > /* set the SW1 and SW2 status bytes (the last two bytes of
> > * the response */
> > - apdu->sw1 = (unsigned int)buf[len - 2];
> > - apdu->sw2 = (unsigned int)buf[len - 1];
> > + apdu->sw1 = buf[len - 2];
> > + apdu->sw2 = buf[len - 1];
>
> the casts here should suppress a warning when turning on some gcc
> warning options afaik
I wonder which one. assigning a char or unsigned char to an int should
always be fine I thought. but we can drop that part as well.
> > --- src/libopensc/log.c (revision 2919)
> > +++ src/libopensc/log.c (working copy)
> > @@ -98,8 +98,8 @@
> > }
> >
> > if (file != NULL) {
> > - r = snprintf(buf, sizeof(buf)-1, "%s:%d:%s: ", file, line, func
> > ? func
> > : ""); - if (r < 0 || (unsigned int)r >= sizeof(buf))
> > + r = snprintf(buf, sizeof(buf), "%s:%d:%s: ", file, line, func ?
> > func :
> > ""); + if (r < 0 || (unsigned int)r > sizeof(buf))
> > return;
>
> should we really discard the debug data when the printed value has been
> truncated ?
right, might not be a good strategy anyway.
change the code to display as much as we can?
log a second line about output being truncated?
Andreas
_______________________________________________
opensc-devel mailing list
[email protected]
http://www.opensc-project.org/mailman/listinfo/opensc-devel