Commit d3203b17 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Misc -llber fixes, lint removal, etc.

parent 4daf3a2c
......@@ -77,7 +77,7 @@ int lutil_mnem2subsys( const char *subsys )
return -1;
}
void lutil_set_all_backends( level )
void lutil_set_all_backends( int level )
{
int i;
......
......@@ -141,11 +141,6 @@ ber_skip_tag( BerElement *ber, ber_len_t *len )
*len = lc;
}
/* BER length should be non-negative */
if( *len < 0 ) {
return LBER_DEFAULT;
}
/* BER element should have enough data left */
if( *len > (ber_len_t) ber_pvt_ber_remaining( ber ) ) {
return LBER_DEFAULT;
......@@ -603,7 +598,7 @@ ber_next_element(
assert( LBER_VALID( ber ) );
if ( ber->ber_ptr == last ) {
if ( ber->ber_ptr >= last ) {
return LBER_DEFAULT;
}
......
......@@ -217,7 +217,7 @@ ber_flush( Sockbuf *sb, BerElement *ber, int freeit )
BER_DUMP(( "liblber", LDAP_LEVEL_DETAIL2, ber, 1 ));
#else
ber_log_printf( LDAP_DEBUG_ANY, sb->sb_debug,
ber_log_printf( LDAP_DEBUG_TRACE, sb->sb_debug,
"ber_flush: %ld bytes to sd %ld%s\n",
towrite, (long) sb->sb_fd,
ber->ber_rwptr != ber->ber_buf ? " (re-flush)" : "" );
......@@ -475,16 +475,14 @@ ber_get_next(
while (ber->ber_rwptr > (char *)&ber->ber_tag && ber->ber_rwptr <
(char *)(&ber->ber_usertag + 1)) {
ber_slen_t i;
ber_slen_t sblen;
char buf[sizeof(ber->ber_len)-1];
ber_len_t tlen = 0;
if ((i=ber_int_sb_read( sb, ber->ber_rwptr,
(char *)(&ber->ber_usertag+1)-ber->ber_rwptr))<=0) {
return LBER_DEFAULT;
}
ber->ber_rwptr += i;
sblen=ber_int_sb_read( sb, ber->ber_rwptr,
(char *)(&ber->ber_usertag+1)-ber->ber_rwptr);
if (sblen<=0) return LBER_DEFAULT;
ber->ber_rwptr += sblen;
/* We got at least one byte, try to parse the tag. */
if (ber->ber_ptr == (char *)&ber->ber_len-1) {
......@@ -492,6 +490,7 @@ ber_get_next(
unsigned char *p = (unsigned char *)ber->ber_ptr;
tag = *p++;
if ((tag & LBER_BIG_TAG_MASK) == LBER_BIG_TAG_MASK) {
ber_len_t i;
for (i=1; (char *)p<ber->ber_rwptr; i++,p++) {
tag <<= 8;
tag |= *p;
......@@ -512,11 +511,12 @@ ber_get_next(
ber->ber_tag = tag;
ber->ber_ptr = (char *)p;
if (i == 1) continue;
if (sblen == 1) continue;
}
/* Now look for the length */
if (*ber->ber_ptr & 0x80) { /* multi-byte */
ber_len_t i;
int llen = *(unsigned char *)ber->ber_ptr++ & 0x7f;
if (llen > (int)sizeof(ber_len_t)) {
errno = ERANGE;
......@@ -526,23 +526,27 @@ ber_get_next(
if (ber->ber_rwptr - ber->ber_ptr < llen) {
return LBER_DEFAULT;
}
for (i=0; i<llen && ber->ber_ptr<ber->ber_rwptr; i++,ber->ber_ptr++) {
for (i=0;
i<llen && ber->ber_ptr<ber->ber_rwptr;
i++,ber->ber_ptr++)
{
tlen <<=8;
tlen |= *(unsigned char *)ber->ber_ptr;
}
} else {
tlen = *(unsigned char *)ber->ber_ptr++;
}
/* Are there leftover data bytes inside ber->ber_len? */
if (ber->ber_ptr < (char *)&ber->ber_usertag) {
if (ber->ber_rwptr < (char *)&ber->ber_usertag)
i = ber->ber_rwptr - ber->ber_ptr;
sblen = ber->ber_rwptr - ber->ber_ptr;
else
i = (char *)&ber->ber_usertag - ber->ber_ptr;
AC_MEMCPY(buf, ber->ber_ptr, i);
ber->ber_ptr += i;
sblen = (char *)&ber->ber_usertag - ber->ber_ptr;
AC_MEMCPY(buf, ber->ber_ptr, sblen);
ber->ber_ptr += sblen;
} else {
i = 0;
sblen = 0;
}
ber->ber_len = tlen;
......@@ -552,7 +556,9 @@ ber_get_next(
if ( ber->ber_len == 0 ) {
errno = ERANGE;
return LBER_DEFAULT;
} else if ( sb->sb_max_incoming && ber->ber_len > sb->sb_max_incoming ) {
}
if ( sb->sb_max_incoming && ber->ber_len > sb->sb_max_incoming ) {
#ifdef NEW_LOGGING
LDAP_LOG( BER, ERR,
"ber_get_next: sockbuf_max_incoming limit hit "
......@@ -572,7 +578,7 @@ ber_get_next(
* make sure ber->ber_len agrees with what we've
* already read.
*/
if ( ber->ber_len < i + l ) {
if ( ber->ber_len < sblen + l ) {
errno = ERANGE;
return LBER_DEFAULT;
}
......@@ -581,19 +587,19 @@ ber_get_next(
return LBER_DEFAULT;
}
ber->ber_end = ber->ber_buf + ber->ber_len;
if (i) {
AC_MEMCPY(ber->ber_buf, buf, i);
if (sblen) {
AC_MEMCPY(ber->ber_buf, buf, sblen);
}
if (l > 0) {
AC_MEMCPY(ber->ber_buf + i, ber->ber_ptr, l);
i += l;
AC_MEMCPY(ber->ber_buf + sblen, ber->ber_ptr, l);
sblen += l;
}
ber->ber_ptr = ber->ber_buf;
ber->ber_usertag = 0;
if ((ber_len_t)i == ber->ber_len) {
if ((ber_len_t)sblen == ber->ber_len) {
goto done;
}
ber->ber_rwptr = ber->ber_buf + i;
ber->ber_rwptr = ber->ber_buf + sblen;
}
}
......@@ -605,8 +611,7 @@ ber_get_next(
assert( to_go > 0 );
res = ber_int_sb_read( sb, ber->ber_rwptr, to_go );
if (res<=0)
return LBER_DEFAULT;
if (res<=0) return LBER_DEFAULT;
ber->ber_rwptr+=res;
if (res<to_go) {
......
......@@ -53,7 +53,7 @@ struct ber_mem_hdr {
};
/* Pattern at top of allocated space */
#define LLBER_MEM_JUNK 0xdeaddadaU
#define LBER_MEM_JUNK 0xdeaddadaU
static const struct ber_mem_hdr ber_int_mem_hdr = { LBER_MEM_JUNK, 0, 0 };
......
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