From: Pierangelo Masarati Date: Thu, 16 Aug 2007 09:23:48 +0000 (+0000) Subject: don't dereference save_errnop if NULL; create temporary file in right dir; revert... X-Git-Tag: OPENLDAP_REL_ENG_2_4_MP~212 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=87f918ebc06b1a4c6d7f26b282c06f24afaea691;p=openldap don't dereference save_errnop if NULL; create temporary file in right dir; revert to strtol(3) (ITS#4627) --- diff --git a/servers/slapd/back-ldif/ldif.c b/servers/slapd/back-ldif/ldif.c index cdbb23be84..5bbd8fe4ff 100644 --- a/servers/slapd/back-ldif/ldif.c +++ b/servers/slapd/back-ldif/ldif.c @@ -182,7 +182,11 @@ spew_entry( Entry * e, struct berval * path, int dolock, int *save_errnop ) int res, spew_res; int entry_length; char * entry_as_string; - char tmpfname[] = "tmpXXXXXX"; + char *tmpfname = NULL; + + tmpfname = ch_malloc( path->bv_len + STRLENOF( "XXXXXX" ) + 1 ); + AC_MEMCPY( tmpfname, path->bv_val, path->bv_len ); + AC_MEMCPY( &tmpfname[ path->bv_len ], "XXXXXX", STRLENOF( "XXXXXX" ) + 1 ); openres = mkstemp( tmpfname ); if ( openres == -1 ) { @@ -264,8 +268,11 @@ spew_entry( Entry * e, struct berval * path, int dolock, int *save_errnop ) unlink( tmpfname ); } - if ( rs != LDAP_SUCCESS ) + ch_free( tmpfname ); + + if ( rs != LDAP_SUCCESS && save_errnop != NULL ) *save_errnop = save_errno; + return rs; } @@ -341,7 +348,7 @@ typedef struct bvlist { struct bvlist *next; struct berval bv; struct berval num; - unsigned int inum; + int inum; int off; } bvlist; @@ -470,7 +477,7 @@ static int r_enum_tree(enumCookie *ck, struct berval *path, if ( ptr ) { itmp.bv_len = ptr - itmp.bv_val; ber_dupbv( &bvl->num, &itmp ); - bvl->inum = strtoul( itmp.bv_val, NULL, 0 ); + bvl->inum = strtol( itmp.bv_val, NULL, 0 ); itmp.bv_val[0] = '\0'; bvl->off = itmp.bv_val - bvl->bv.bv_val; }