Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F111649601
D22398.id64599.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D22398.id64599.diff
View Options
Index: sys/sys/bitstring.h
===================================================================
--- sys/sys/bitstring.h
+++ 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);
@@ -231,6 +236,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);
Index: tests/sys/sys/bitstring_test.c
===================================================================
--- tests/sys/sys/bitstring_test.c
+++ 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
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 7, 12:28 PM (20 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17032087
Default Alt Text
D22398.id64599.diff (1 KB)
Attached To
Mode
D22398: bitstring: exit early if _start is past size of the bitstring
Attached
Detach File
Event Timeline
Log In to Comment