pike.git/
src/
stralloc.c
Branch:
Tag:
Non-build tags
All tags
No tags
2015-12-12
2015-12-12 16:34:17 by Arne Goedeke <el@laramies.com>
1b420526c1022c6b6dec6a68e07394f5d894a8b5 (
9
lines) (+
8
/-
1
)
[
Show
|
Annotate
]
Branch:
8.1
Strings: added some overflow checks
757:
PMOD_EXPORT struct pike_string *debug_begin_wide_shared_string(size_t len, enum size_shift shift) { struct pike_string *t = NULL;
-
size_t bytes
= (len+1) << shift
;
+
size_t bytes;
ONERROR fe;
-
+
+
if ((ptrdiff_t)len < 0 || DO_SIZE_T_ADD_OVERFLOW(len, 1, &bytes) ||
+
DO_SIZE_T_MUL_OVERFLOW(bytes, 1 << shift, &bytes)) {
+
Pike_error("String is too large.\n");
+
}
+
#ifdef PIKE_DEBUG if(d_flag>10) verify_shared_strings_tables();