Skip to contentSkip to conversation

Add checking of out-of-range on Choices' index values

PATCH In review Jing Min Zhao 2 participants 2 messages Jul 4, 2007 – Jul 5, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add checking of out-of-range on Choices' index values

Choices' index values may be out of range while still encoded in the fixed length bit-field. This bug may cause access to undefined types (NULL pointers) and thus crashes (Reported by Zhongling Wen).

This patch also adds checking of decode flag when decoding SEQUENCEs.

---
 net/netfilter/nf_conntrack_h323_asn1.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
net/netfilter/nf_conntrack_h323_asn1.c +3 -1
index f6fad71..6b7eaa0 100644
@@ -518,7 +518,7 @@ int decode_seq(bitstr_t * bs, field_t * f, char *base, int level)
 			CHECK_BOUND(bs, 2);
 			len = get_len(bs);
 			CHECK_BOUND(bs, len);
-			if (!base) {
+			if (!base || !(son->attr & DECODE)) {
 				PRINT("%*.s%s\n", (level + 1) * TAB_SIZE,
 				      " ", son->name);
 				bs->cur += len;
@@ -704,6 +704,8 @@ int decode_choice(bitstr_t * bs, field_t * f, char *base, int level)
 	} else {
 		ext = 0;
 		type = get_bits(bs, f->sz);
+		if (type >= f->lb)
+			return H323_ERROR_RANGE;
 	}
 
 	/* Write Type */
Signature · 1 line
1.4.4.3
#1 lore raw
Quoted 3 lines · Jing Min Zhao

Choices' index values may be out of range while still encoded in the fixed length bit-field. This bug may cause access to undefined types (NULL pointers) and thus crashes (Reported by Zhongling Wen).

This patch also adds checking of decode flag when decoding SEQUENCEs.

Thanks for fixing this so quickly, applied. I'll also push the patch to -stable.