#3 invalid memory access

open
nobody
None
5
2010-07-05
2010-07-05
David Tardon
No

GetOpt option parser writes to main_options->files outside of allocated memory if detox is started with 11 or more files.

Version:
detox-1.2.0

Steps to reproduce:
1. touch a b c d e f g h i j k
2. valgrind --track-origins=yes detox a b c d e f g h i j k

Valgrind output:
==1057== Invalid write of size 8
==1057== at 0x405D20: parse_options_getopt (parse_options_getopt.c:185)
==1057== by 0x4012B5: main (detox.c:84)
==1057== Address 0x4c25200 is 0 bytes after a block of size 80 alloc'd
==1057== at 0x4A05255: realloc (vg_replace_malloc.c:476)
==1057== by 0x405D39: parse_options_getopt (parse_options_getopt.c:187)
==1057== by 0x4012B5: main (detox.c:84)

Discussion