Commit f6db6d33 authored by Jong Hyuk Choi's avatar Jong Hyuk Choi
Browse files

misc cleanup

parent f4e00751
...@@ -356,8 +356,10 @@ slap_parse_sync_cookie( ...@@ -356,8 +356,10 @@ slap_parse_sync_cookie(
{ {
char *csn_ptr; char *csn_ptr;
char *csn_str; char *csn_str;
char *csn_str_val;
char *sid_ptr; char *sid_ptr;
char *sid_str; char *sid_str;
char *sid_str_val;
char *cval; char *cval;
struct berval *ctxcsn; struct berval *ctxcsn;
...@@ -365,11 +367,12 @@ slap_parse_sync_cookie( ...@@ -365,11 +367,12 @@ slap_parse_sync_cookie(
return -1; return -1;
if (( csn_ptr = strstr( cookie->octet_str[0].bv_val, "csn=" )) != NULL ) { if (( csn_ptr = strstr( cookie->octet_str[0].bv_val, "csn=" )) != NULL ) {
csn_str = (char *) strndup( csn_ptr, LDAP_LUTIL_CSNSTR_BUFSIZE ); csn_str = (char *) SLAP_STRNDUP( csn_ptr, LDAP_LUTIL_CSNSTR_BUFSIZE );
csn_str_val = csn_str + sizeof("csn=") - 1;
if ( cval = strchr( csn_str, ',' )) { if ( cval = strchr( csn_str, ',' )) {
*cval = '\0'; *cval = '\0';
} }
ctxcsn = ber_str2bv( csn_str + 4, strlen(csn_str) - 4, 1, NULL ); ctxcsn = ber_str2bv( csn_str_val, strlen(csn_str_val), 1, NULL );
ch_free( csn_str ); ch_free( csn_str );
ber_bvarray_add( &cookie->ctxcsn, ctxcsn ); ber_bvarray_add( &cookie->ctxcsn, ctxcsn );
ch_free( ctxcsn ); ch_free( ctxcsn );
...@@ -378,11 +381,13 @@ slap_parse_sync_cookie( ...@@ -378,11 +381,13 @@ slap_parse_sync_cookie(
} }
if (( sid_ptr = strstr( cookie->octet_str->bv_val, "sid=" )) != NULL ) { if (( sid_ptr = strstr( cookie->octet_str->bv_val, "sid=" )) != NULL ) {
sid_str = (char *) strndup( sid_ptr, 7 ); sid_str = (char *) SLAP_STRNDUP( sid_ptr,
SLAP_SYNC_SID_SIZE + sizeof("sid=") - 1 );
sid_str_val = sid_str + sizeof("sid=") - 1;
if ( cval = strchr( sid_str, ',' )) { if ( cval = strchr( sid_str, ',' )) {
*cval = '\0'; *cval = '\0';
} }
cookie->sid = atoi( sid_str+4 ); cookie->sid = atoi( sid_str_val );
ch_free( sid_str ); ch_free( sid_str );
} else { } else {
cookie->sid = -1; cookie->sid = -1;
......
...@@ -1287,6 +1287,12 @@ typedef BackendDB Backend; ...@@ -1287,6 +1287,12 @@ typedef BackendDB Backend;
#define nbackends nBackendDB #define nbackends nBackendDB
#define backends backendDB #define backends backendDB
/*
* syncinfo structure for syncrepl
*/
#define SLAP_SYNC_SID_SIZE 3
struct nonpresent_entry { struct nonpresent_entry {
struct berval *npe_name; struct berval *npe_name;
struct berval *npe_nname; struct berval *npe_nname;
...@@ -1299,9 +1305,6 @@ struct sync_cookie { ...@@ -1299,9 +1305,6 @@ struct sync_cookie {
struct berval *octet_str; struct berval *octet_str;
}; };
/*
* syncinfo structure for syncrepl
*/
typedef struct syncinfo_s { typedef struct syncinfo_s {
struct slap_backend_db *si_be; struct slap_backend_db *si_be;
unsigned int si_id; unsigned int si_id;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment