Page MenuHomeFreeBSD

D22398.diff
No OneTemporary

D22398.diff

Index: head/sys/sys/bitstring.h
===================================================================
--- head/sys/sys/bitstring.h
+++ head/sys/sys/bitstring.h
@@ -202,6 +202,11 @@
bitstr_t _test;
int _value, _offset;
+ if (_start >= _nbits) {
+ *_result = -1;
+ return;
+ }
+
if (_nbits > 0) {
_curbitstr = _bitstr + _bit_idx(_start);
_stopbitstr = _bitstr + _bit_idx(_nbits - 1);
@@ -230,6 +235,11 @@
bitstr_t *_stopbitstr;
bitstr_t _test;
int _value, _offset;
+
+ if (_start >= _nbits) {
+ *_result = -1;
+ return;
+ }
if (_nbits > 0) {
_curbitstr = _bitstr + _bit_idx(_start);
Index: head/tests/sys/sys/bitstring_test.c
===================================================================
--- head/tests/sys/sys/bitstring_test.c
+++ head/tests/sys/sys/bitstring_test.c
@@ -246,6 +246,17 @@
nbits, memloc, i, found_set_bit);
}
}
+
+ /* Pass a start value beyond the size of the bit string */
+ bit_ffs_at(bitstr, nbits, nbits, &found_set_bit);
+ ATF_REQUIRE_MSG(found_set_bit == -1,
+ "bit_ffs_at_%d_%s: Failed with high start value of %d, Result %d",
+ nbits, memloc, nbits, found_set_bit);
+
+ bit_ffs_at(bitstr, nbits + 3, nbits, &found_set_bit);
+ ATF_REQUIRE_MSG(found_set_bit == -1,
+ "bit_ffs_at_%d_%s: Failed with high start value of %d, Result %d",
+ nbits, memloc, nbits + 3, found_set_bit);
}
BITSTRING_TC_DEFINE(bit_ffc_at)
@@ -297,6 +308,17 @@
nbits, memloc, i, found_clear_bit);
}
}
+
+ /* Pass a start value beyond the size of the bit string */
+ bit_ffc_at(bitstr, nbits, nbits, &found_clear_bit);
+ ATF_REQUIRE_MSG(found_clear_bit == -1,
+ "bit_ffc_at_%d_%s: Failed with high start value, Result %d",
+ nbits, memloc, found_clear_bit);
+
+ bit_ffc_at(bitstr, nbits + 3, nbits, &found_clear_bit);
+ ATF_REQUIRE_MSG(found_clear_bit == -1,
+ "bit_ffc_at_%d_%s: Failed with high start value of %d, Result %d",
+ nbits, memloc, nbits + 3, found_clear_bit);
}
BITSTRING_TC_DEFINE(bit_nclear)

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 7, 2:14 AM (13 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17023514
Default Alt Text
D22398.diff (1 KB)

Event Timeline