Skip to content
Snippets Groups Projects
Commit 0d7f51ef authored by Quanah Gibson-Mount's avatar Quanah Gibson-Mount
Browse files

ITS#5699

parent d7fef051
No related branches found
No related tags found
No related merge requests found
OpenLDAP 2.4 Change Log OpenLDAP 2.4 Change Log
OpenLDAP 2.4.13 Engineering OpenLDAP 2.4.13 Engineering
Fixed liblutil hex conversion (ITS#5699)
Fixed slapd-bdb/hdb invalid db crash (ITS#5698) Fixed slapd-bdb/hdb invalid db crash (ITS#5698)
OpenLDAP 2.4.12 Release (2008/10/12) OpenLDAP 2.4.12 Release (2008/10/12)
......
...@@ -695,7 +695,6 @@ lutil_str2bin( struct berval *in, struct berval *out, void *ctx ) ...@@ -695,7 +695,6 @@ lutil_str2bin( struct berval *in, struct berval *out, void *ctx )
{ {
char *pin, *pout, ctmp; char *pin, *pout, ctmp;
char *end; char *end;
long l;
int i, chunk, len, rc = 0, hex = 0; int i, chunk, len, rc = 0, hex = 0;
if ( !out || !out->bv_val || out->bv_len < in->bv_len ) if ( !out || !out->bv_val || out->bv_len < in->bv_len )
return -1; return -1;
...@@ -718,38 +717,40 @@ lutil_str2bin( struct berval *in, struct berval *out, void *ctx ) ...@@ -718,38 +717,40 @@ lutil_str2bin( struct berval *in, struct berval *out, void *ctx )
} }
if ( hex ) { if ( hex ) {
#define HEXMAX (2 * sizeof(long)) #define HEXMAX (2 * sizeof(long))
unsigned long l;
/* Convert a longword at a time, but handle leading /* Convert a longword at a time, but handle leading
* odd bytes first * odd bytes first
*/ */
chunk = len & (HEXMAX-1); chunk = len % HEXMAX;
if ( !chunk ) if ( !chunk )
chunk = HEXMAX; chunk = HEXMAX;
while ( len ) { while ( len ) {
int ochunk;
ctmp = pin[chunk]; ctmp = pin[chunk];
pin[chunk] = '\0'; pin[chunk] = '\0';
errno = 0; errno = 0;
l = strtol( pin, &end, 16 ); l = strtoul( pin, &end, 16 );
pin[chunk] = ctmp; pin[chunk] = ctmp;
if ( errno ) if ( errno )
return -1; return -1;
chunk++; ochunk = (chunk + 1)/2;
chunk >>= 1; for ( i = ochunk - 1; i >= 0; i-- ) {
for ( i = chunk; i>=0; i-- ) {
pout[i] = l & 0xff; pout[i] = l & 0xff;
l >>= 8; l >>= 8;
} }
pin += chunk; pin += chunk;
pout += sizeof(long); pout += ochunk;
len -= chunk; len -= chunk;
chunk = HEXMAX; chunk = HEXMAX;
} }
out->bv_len = pout + len - out->bv_val; out->bv_len = pout - out->bv_val;
} else { } else {
/* Decimal */ /* Decimal */
char tmpbuf[64], *tmp; char tmpbuf[64], *tmp;
lutil_int_decnum num; lutil_int_decnum num;
int neg = 0; int neg = 0;
long l;
len = in->bv_len; len = in->bv_len;
pin = in->bv_val; pin = in->bv_val;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment