chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a050646
)
util: check for overflows in xbsearch_r()
author
Lennart Poettering
<lennart@poettering.net>
Tue, 27 Mar 2018 12:56:04 +0000
(14:56 +0200)
committer
Sven Eden
<yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000
(16:47 +0200)
src/basic/util.c
patch
|
blob
|
history
diff --git
a/src/basic/util.c
b/src/basic/util.c
index e096e3194cdceea88848e583e2f53c49317d3ca7..3ea2e6f67f37fa65a87242b08bcc845c55fcda97 100644
(file)
--- a/
src/basic/util.c
+++ b/
src/basic/util.c
@@
-186,11
+186,13
@@
void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
const void *p;
int comparison;
+ assert(!size_multiply_overflow(nmemb, size));
+
l = 0;
u = nmemb;
while (l < u) {
idx = (l + u) / 2;
- p = (const
char
*) base + idx * size;
+ p = (const
uint8_t
*) base + idx * size;
comparison = compar(key, p, arg);
if (comparison < 0)
u = idx;