summaryrefslogtreecommitdiffstats
path: root/libiptc
diff options
context:
space:
mode:
authorrusty <rusty>2000-08-26 04:39:16 +0000
committerrusty <rusty>2000-08-26 04:39:16 +0000
commitb536206a996b5f2e6c6d9ef1b3c84ada50d8e232 (patch)
tree7279a01e382c28a73417fc21da052d03ee3b0e29 /libiptc
parent0395d0f3a398655d11dc72a6afe1d2ff7909dacc (diff)
Handle *really* large index values without segfaulting.
Diffstat (limited to 'libiptc')
-rw-r--r--libiptc/libiptc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c
index 781a42d..68b5a14 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;
}