]> git.ipfire.org Git - thirdparty/iproute2.git/commit
ss: avoid passing negative numbers to malloc
authorAndreas Henriksson <andreas@fatal.se>
Wed, 13 Nov 2013 08:46:42 +0000 (09:46 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Sat, 23 Nov 2013 01:09:10 +0000 (17:09 -0800)
commit2a4fa1c305742e4bfbc2960c40e0d1ee55b30694
treea135fd72c9b16c6ca40289614fe5d313e6f68c7f
parent978703348172c8d7753d552543469fdf6e1bef21
ss: avoid passing negative numbers to malloc

Example:

$ ss state established \( sport = :4060  or sport = :4061 or sport = :4062  or sport = :4063 or sport = :4064  or sport = :4065 or sport = :4066  or sport = :4067 \)  > /dev/null
Aborted

In the example above ssfilter_bytecompile(...) will return (int)136.
char l1 = 136; means -120 which will result in a negative number
being passed to malloc at misc/ss.c:913.

Simply declare l1 and l2 as integers to avoid the char overflow.

This is one of the issues originally reported in http://bugs.debian.org/511720

Fix the same problem in other code paths as well (thanks to Eric Dumazet).

Reported-by: Andreas Schuldei <andreas@debian.org>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Reviewed-by: Eric Dumazet <edumazet@google.com>
misc/ss.c