Skip to contentSkip to conversation

H.323: Check range first in sequence extension

PATCH Applied Jing Min Zhao 2 participants 2 messages May 17, 2007 – May 24, 2007

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

PATCH 4/4 H.323: Check range first in sequence extension

Check range before checking STOP flag. This optimization may save a nanosecond or less :)

---
 net/netfilter/nf_conntrack_h323_asn1.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
net/netfilter/nf_conntrack_h323_asn1.c +9 -9
index f6fad71..ceb39bd 100644
@@ -555,15 +555,6 @@ int decode_seq(bitstr_t * bs, field_t * f, char *base, int level)
 
 	/* Decode the extension components */
 	for (opt = 0; opt < bmp2_len; opt++, i++, son++) {
-		if (i < f->ub && son->attr & STOP) {
-			PRINT("%*.s%s\n", (level + 1) * TAB_SIZE, " ",
-			      son->name);
-			return H323_ERROR_STOP;
-		}
-
-		if (!((0x80000000 >> opt) & bmp2))	/* Not present */
-			continue;
-
 		/* Check Range */
 		if (i >= f->ub) {	/* Newer Version? */
 			CHECK_BOUND(bs, 2);
@@ -573,6 +564,15 @@ int decode_seq(bitstr_t * bs, field_t * f, char *base, int level)
 			continue;
 		}
 
+		if (son->attr & STOP) {
+			PRINT("%*.s%s\n", (level + 1) * TAB_SIZE, " ",
+			      son->name);
+			return H323_ERROR_STOP;
+		}
+
+		if (!((0x80000000 >> opt) & bmp2))	/* Not present */
+			continue;
+
 		CHECK_BOUND(bs, 2);
 		len = get_len(bs);
 		CHECK_BOUND(bs, len);
Signature · 1 line
1.4.4.3
#1 lore raw
Quoted 1 line · Jing Min Zhao

Check range before checking STOP flag. This optimization may save a nanosecond or less :)

I'll queue this one for 2.6.23 since its a not too important optimization.