patches/liblber.dif
author rohinis
Tue, 29 Nov 2011 17:32:55 +0000
branchs11express-2010-11
changeset 22234 c23e64da3e06
parent 9397 b16e349d18c5
permissions -rw-r--r--
2011-11-29 Rohini S <[email protected]> * patches/Python26-22-audio.diff: Fixes CVE-2010-1634 * specs/SUNWPython26.spec: Fixes CR 7085446
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     1
--- libraries/liblber/io.c	2003/01/23 14:17:29	1.1
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     2
+++ libraries/liblber/io.c	2003/01/23 14:19:27
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     3
@@ -475,16 +475,14 @@
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     4
 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     5
 	while (ber->ber_rwptr > (char *)&ber->ber_tag && ber->ber_rwptr <
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     6
 		(char *)(&ber->ber_usertag + 1)) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     7
-		ber_slen_t i;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     8
+		ber_slen_t sblen;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     9
 		char buf[sizeof(ber->ber_len)-1];
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    10
 		ber_len_t tlen = 0;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    11
 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    12
-		if ((i=ber_int_sb_read( sb, ber->ber_rwptr,
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    13
-			(char *)(&ber->ber_usertag+1)-ber->ber_rwptr))<=0) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    14
-			return LBER_DEFAULT;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    15
-		}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    16
-
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    17
-		ber->ber_rwptr += i;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    18
+		sblen=ber_int_sb_read( sb, ber->ber_rwptr,
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    19
+			(char *)(&ber->ber_usertag+1)-ber->ber_rwptr);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    20
+		if (sblen<=0) return LBER_DEFAULT;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    21
+		ber->ber_rwptr += sblen;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    22
 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    23
 		/* We got at least one byte, try to parse the tag. */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    24
 		if (ber->ber_ptr == (char *)&ber->ber_len-1) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    25
@@ -492,6 +490,7 @@
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    26
 			unsigned char *p = (unsigned char *)ber->ber_ptr;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    27
 			tag = *p++;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    28
 			if ((tag & LBER_BIG_TAG_MASK) == LBER_BIG_TAG_MASK) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    29
+				ber_len_t i;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    30
 				for (i=1; (char *)p<ber->ber_rwptr; i++,p++) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    31
 					tag <<= 8;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    32
 					tag |= *p;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    33
@@ -511,12 +510,14 @@
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    34
 			}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    35
 			ber->ber_tag = tag;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    36
 			ber->ber_ptr = (char *)p;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    37
+		
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    38
+			if (sblen == 1) continue;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    39
 		}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    40
 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    41
-		if (i == 1) continue;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    42
 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    43
 		/* Now look for the length */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    44
 		if (*ber->ber_ptr & 0x80) {	/* multi-byte */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    45
+			ber_len_t i;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    46
 			int llen = *(unsigned char *)ber->ber_ptr++ & 0x7f;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    47
 			if (llen > (int)sizeof(ber_len_t)) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    48
 				errno = ERANGE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    49
@@ -526,23 +527,27 @@
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    50
 			if (ber->ber_rwptr - ber->ber_ptr < llen) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    51
 				return LBER_DEFAULT;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    52
 			}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    53
-			for (i=0; i<llen && ber->ber_ptr<ber->ber_rwptr; i++,ber->ber_ptr++) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    54
+			for (i=0;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    55
+				i<llen && ber->ber_ptr<ber->ber_rwptr;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    56
+				i++,ber->ber_ptr++)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    57
+			{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    58
 				tlen <<=8;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    59
 				tlen |= *(unsigned char *)ber->ber_ptr;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    60
 			}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    61
 		} else {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    62
 			tlen = *(unsigned char *)ber->ber_ptr++;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    63
 		}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    64
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    65
 		/* Are there leftover data bytes inside ber->ber_len? */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    66
 		if (ber->ber_ptr < (char *)&ber->ber_usertag) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    67
 			if (ber->ber_rwptr < (char *)&ber->ber_usertag)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    68
-				i = ber->ber_rwptr - ber->ber_ptr;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    69
+				sblen = ber->ber_rwptr - ber->ber_ptr;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    70
 			else
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    71
-				i = (char *)&ber->ber_usertag - ber->ber_ptr;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    72
-			AC_MEMCPY(buf, ber->ber_ptr, i);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    73
-			ber->ber_ptr += i;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    74
+				sblen = (char *)&ber->ber_usertag - ber->ber_ptr;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    75
+			AC_MEMCPY(buf, ber->ber_ptr, sblen);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    76
+			ber->ber_ptr += sblen;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    77
 		} else {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    78
-			i = 0;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    79
+			sblen = 0;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    80
 		}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    81
 		ber->ber_len = tlen;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    82
 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    83
@@ -552,7 +557,9 @@
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    84
 		if ( ber->ber_len == 0 ) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    85
 			errno = ERANGE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    86
 			return LBER_DEFAULT;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    87
-		} else if ( sb->sb_max_incoming && ber->ber_len > sb->sb_max_incoming ) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    88
+		}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    89
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    90
+		if ( sb->sb_max_incoming && ber->ber_len > sb->sb_max_incoming ) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    91
 #ifdef NEW_LOGGING
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    92
 			LDAP_LOG( BER, ERR, 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    93
 				"ber_get_next: sockbuf_max_incoming limit hit "
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    94
@@ -572,7 +579,7 @@
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    95
 			 * make sure ber->ber_len agrees with what we've
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    96
 			 * already read.
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    97
 			 */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    98
-			if ( ber->ber_len < i + l ) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    99
+			if ( ber->ber_len < sblen + l ) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   100
 				errno = ERANGE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   101
 				return LBER_DEFAULT;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   102
 			}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   103
@@ -581,19 +588,19 @@
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   104
 				return LBER_DEFAULT;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   105
 			}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   106
 			ber->ber_end = ber->ber_buf + ber->ber_len;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   107
-			if (i) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   108
-				AC_MEMCPY(ber->ber_buf, buf, i);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   109
+			if (sblen) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   110
+				AC_MEMCPY(ber->ber_buf, buf, sblen);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   111
 			}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   112
 			if (l > 0) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   113
-				AC_MEMCPY(ber->ber_buf + i, ber->ber_ptr, l);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   114
-				i += l;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   115
+				AC_MEMCPY(ber->ber_buf + sblen, ber->ber_ptr, l);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   116
+				sblen += l;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   117
 			}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   118
 			ber->ber_ptr = ber->ber_buf;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   119
 			ber->ber_usertag = 0;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   120
-			if ((ber_len_t)i == ber->ber_len) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   121
+			if ((ber_len_t)sblen == ber->ber_len) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   122
 				goto done;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   123
 			}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   124
-			ber->ber_rwptr = ber->ber_buf + i;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   125
+			ber->ber_rwptr = ber->ber_buf + sblen;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   126
 		}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   127
 	}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   128
 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   129
@@ -605,8 +612,7 @@
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   130
 		assert( to_go > 0 );
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   131
 		
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   132
 		res = ber_int_sb_read( sb, ber->ber_rwptr, to_go );
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   133
-		if (res<=0)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   134
-			return LBER_DEFAULT;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   135
+		if (res<=0) return LBER_DEFAULT;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   136
 		ber->ber_rwptr+=res;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   137
 		
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   138
 		if (res<to_go) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   139
--- libraries/liblber/decode.c	2003/01/23 14:17:37	1.1
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   140
+++ libraries/liblber/decode.c	2003/01/23 14:17:43
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   141
@@ -603,7 +603,7 @@
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   142
 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   143
 	assert( LBER_VALID( ber ) );
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   144
 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   145
-	if ( ber->ber_ptr == last ) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   146
+	if ( ber->ber_ptr >= last ) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   147
 		return LBER_DEFAULT;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   148
 	}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   149