diff options
author | Rusty Russell <rusty@linuxcare.com.au> | 2000-08-26 04:39:16 +0000 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2000-08-26 04:39:16 +0000 |
commit | 2ee3fd0a8d4b1ab65cb4077650cda174b779e6f9 (patch) | |
tree | 7279a01e382c28a73417fc21da052d03ee3b0e29 /libiptc | |
parent | 4107c8dc6520a5a969f8ff936f9f923910fcbffc (diff) |
Handle *really* large index values without segfaulting.
Diffstat (limited to 'libiptc')
-rw-r--r-- | libiptc/libiptc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c index 781a42db..68b5a149 100644 --- a/libiptc/libiptc.c +++ b/libiptc/libiptc.c @@ -908,6 +908,7 @@ TC_INSERT_ENTRY(const IPT_CHAINLABEL chain, unsigned int chainindex, offset; STRUCT_ENTRY_TARGET old; struct chain_cache *c; + STRUCT_ENTRY *e; int ret; iptc_fn = TC_INSERT_ENTRY; @@ -918,7 +919,8 @@ TC_INSERT_ENTRY(const IPT_CHAINLABEL chain, chainindex = entry2index(*handle, c->start); - if (index2entry(*handle, chainindex + rulenum) > c->end) { + e = index2entry(*handle, chainindex + rulenum); + if (!e || e > c->end) { errno = E2BIG; return 0; } @@ -945,6 +947,7 @@ TC_REPLACE_ENTRY(const IPT_CHAINLABEL chain, unsigned int chainindex, offset; STRUCT_ENTRY_TARGET old; struct chain_cache *c; + STRUCT_ENTRY *e; int ret; iptc_fn = TC_REPLACE_ENTRY; @@ -956,7 +959,8 @@ TC_REPLACE_ENTRY(const IPT_CHAINLABEL chain, chainindex = entry2index(*handle, c->start); - if (index2entry(*handle, chainindex + rulenum) >= c->end) { + e = index2entry(*handle, chainindex + rulenum); + if (!e || e >= c->end) { errno = E2BIG; return 0; } |