numam-dpdk/lib/librte_cmdline
Alan Carew aaa662e75c cmdline: fix overflow on bsd
When using test-pmd with flow director in FreeBSD, the application will
segfault/Bus error while parsing the command-line. This is due to how
each commands result structure is represented during parsing, where the offsets
for each tokens value is stored in a character array(char result_buf[BUFSIZ])
in cmdline_parse()(./lib/librte_cmdline/cmdline_parse.c).

The overflow occurs where BUFSIZ is less than the size of a commands result
structure, in this case "struct cmd_pkt_filter_result"
(app/test-pmd/cmdline.c) is 1088 bytes and BUFSIZ on FreeBSD is 1024 bytes as
opposed to 8192 bytes on Linux.

The problem can be reproduced by running test-pmd on FreeBSD:
./testpmd -c 0x3 -n 4 -- -i --portmask=0x3 --pkt-filter-mode=perfect
And adding a filter:
add_perfect_filter 0 udp src 192.168.0.0 1024 dst 192.168.0.0 1024 flexbytes
0x800 vlan 0 queue 0 soft 0x17

This patch removes the OS dependency on BUFSIZ and defines and uses a
library #define CMDLINE_PARSE_RESULT_BUFSIZE 8192

Added boundary checking to ensure this buffer size cannot overflow, with
an error message being produced.

Suggested-by: Olivier Matz <olivier.matz@6wind.com>
http://git.droids-corp.org/?p=libcmdline.git;a=commitdiff;h=b1d5b169352e57df3fc14c51ffad4b83f3e5613f

Signed-off-by: Alan Carew <alan.carew@intel.com>
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Tested-by: Bruce Richardson <bruce.richardson@intel.com>
2014-12-05 16:54:53 +01:00
..
cmdline_cirbuf.c remove trailing whitespaces 2014-06-11 00:29:34 +02:00
cmdline_cirbuf.h remove trailing whitespaces 2014-06-11 00:29:34 +02:00
cmdline_parse_etheraddr.c cmdline: fix overflow on bsd 2014-12-05 16:54:53 +01:00
cmdline_parse_etheraddr.h cmdline: fix overflow on bsd 2014-12-05 16:54:53 +01:00
cmdline_parse_ipaddr.c cmdline: fix overflow on bsd 2014-12-05 16:54:53 +01:00
cmdline_parse_ipaddr.h cmdline: fix overflow on bsd 2014-12-05 16:54:53 +01:00
cmdline_parse_num.c cmdline: fix overflow on bsd 2014-12-05 16:54:53 +01:00
cmdline_parse_num.h cmdline: fix overflow on bsd 2014-12-05 16:54:53 +01:00
cmdline_parse_portlist.c cmdline: fix overflow on bsd 2014-12-05 16:54:53 +01:00
cmdline_parse_portlist.h cmdline: fix overflow on bsd 2014-12-05 16:54:53 +01:00
cmdline_parse_string.c cmdline: fix overflow on bsd 2014-12-05 16:54:53 +01:00
cmdline_parse_string.h cmdline: fix overflow on bsd 2014-12-05 16:54:53 +01:00
cmdline_parse.c cmdline: fix overflow on bsd 2014-12-05 16:54:53 +01:00
cmdline_parse.h cmdline: fix overflow on bsd 2014-12-05 16:54:53 +01:00
cmdline_rdline.c remove trailing whitespaces 2014-06-11 00:29:34 +02:00
cmdline_rdline.h remove trailing whitespaces 2014-06-11 00:29:34 +02:00
cmdline_socket.c cmdline: fix for bsd 2014-11-24 13:17:49 +01:00
cmdline_socket.h remove trailing whitespaces 2014-06-11 00:29:34 +02:00
cmdline_vt100.c remove trailing whitespaces 2014-06-11 00:29:34 +02:00
cmdline_vt100.h remove trailing whitespaces 2014-06-11 00:29:34 +02:00
cmdline.c fix unix permissions for source files 2014-08-28 17:04:01 +02:00
cmdline.h cmdline: fix for bsd 2014-11-24 13:17:49 +01:00
Makefile remove trailing whitespaces 2014-06-11 00:29:34 +02:00