[Date Prev][Date Next] [Chronological] [Thread] [Top]

sasl_errdetail result needs strdup (ITS#2590)



Full_Name: Paul Nelson
Version: 2.1.17
OS: Mac OS X
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (208.7.44.100)


In the source file cyrus.c:

Line 625 is an example where sasl_errdetail is called and the result is saved in
ld->ld_error.

ld->ld_error is later freed in other parts of ldap, but the sasl library also
frees the value it returned from sasl_errdetail.

I believe the correct code should strdup the value returned from sasl_errdetail
as follows:
625c625
<               ld->ld_error = (char *)sasl_errdetail( ctx );
---
>               ld->ld_error = LDAP_STRDUP((char *)sasl_errdetail( ctx ));
722c722
<                       ld->ld_error = (char *)sasl_errdetail( ctx );
---
>                       ld->ld_error = LDAP_STRDUP((char *)sasl_errdetail( ctx
));
733c733
<               ld->ld_error = (char *)sasl_errdetail( ctx );
---
>               ld->ld_error = LDAP_STRDUP((char *)sasl_errdetail( ctx ));


The extra free can result in memory allocation trouble later on, ranging from no
big deal to real trouble on multi-threaded apps.