mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 22:33:37 +01:00
help avoid overflow from len_in + (len_in/n)*len_ins
nick, do you think this does it? if so, we should maybe backport too. svn:r3334
This commit is contained in:
parent
4b6d55afdf
commit
74bc4e5af0
@ -215,6 +215,8 @@ int tor_strpartition(char *dest, size_t dest_len,
|
|||||||
tor_assert(dest_len < SIZE_T_CEILING);
|
tor_assert(dest_len < SIZE_T_CEILING);
|
||||||
len_in = strlen(s);
|
len_in = strlen(s);
|
||||||
len_ins = strlen(insert);
|
len_ins = strlen(insert);
|
||||||
|
tor_assert(len_in < SIZE_T_CEILING);
|
||||||
|
tor_assert(len_in/n < SIZE_T_CEILING/len_ins); /* avoid overflow */
|
||||||
len_out = len_in + (len_in/n)*len_ins;
|
len_out = len_in + (len_in/n)*len_ins;
|
||||||
is_even = (len_in%n) == 0;
|
is_even = (len_in%n) == 0;
|
||||||
switch (rule)
|
switch (rule)
|
||||||
|
Loading…
Reference in New Issue
Block a user