test/eal: fix incorrect array sizes
PATCH 1/1 test/eal: fix incorrect array sizes
Following removal of -c and -n options, the array should have been shrunk to avoid launch_proc to access unitialised strings.
--- app/test/test_eal_flags.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
app/test/test_eal_flags.c +3 -3
@@ -244,7 +244,7 @@ test_whitelist_flag(void)snprintf (prefix,sizeof (prefix),"--file-prefix=%s" , tmp);#endif -const char *wlinval[][11 ] = { +const char *wlinval[][7 ] = { {prgname, prefix, mp_flag, pci_whitelist,"error" ,"" ,"" }, {prgname, prefix, mp_flag,
@@ -310,7 +310,7 @@ test_invalid_b_flag(void)snprintf (prefix,sizeof (prefix),"--file-prefix=%s" , tmp);#endif -const char *blinval[][9 ] = { +const char *blinval[][5 ] = { {prgname, prefix, mp_flag,"-b" ,"error" }, {prgname, prefix, mp_flag,"-b" ,"0:0:0" }, {prgname, prefix, mp_flag,"-b" ,"0:error:0.1" },
@@ -414,7 +414,7 @@ test_invalid_r_flag(void)snprintf (prefix,sizeof (prefix),"--file-prefix=%s" , tmp);#endif -const char *rinval[][9 ] = { +const char *rinval[][5 ] = { {prgname, prefix, mp_flag,"-r" ,"error" }, {prgname, prefix, mp_flag,"-r" ,"0" }, {prgname, prefix, mp_flag,"-r" ,"-1" },
Signature · 1 line
1.8.3.1
Quoted 8 lines · David Marchand
Following removal of -c and -n options, the array should have been shrunk to avoid
launch_procto access unitialised strings.Fixes b4dbacdb1ad7 ("test/eal: set core mask/list config only in dedicated test")Fixes 501fa9a40298 ("test/eal: set memory channel config only in dedicated test")Signed-off-by David Marchand <[email protected]>
Good patch, but is it just me or are you off by one in some places? see inline
Quoted 9 lines
--- app/test/test_eal_flags.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)app/test/test_eal_flags.c +0
-0
app/test/test_eal_flags.c test_whitelist_flag(void) · line 247
Quoted 5 lines
app/test/test_eal_flags.c +1
-1@@ -244,7 +244,7 @@ test_whitelist_flag(void)snprintf (prefix,sizeof (prefix),"--file-prefix=%s" , tmp);#endif -const char *wlinval[][11 ] = { +const char *wlinval[][7 ] = {
Shoudln't this be wlinval[][6]?
app/test/test_eal_flags.c test_invalid_b_flag(void) · line 313
Quoted 9 lines
app/test/test_eal_flags.c +1
-1{prgname, prefix, mp_flag, pci_whitelist, "error", "", ""}, {prgname, prefix, mp_flag,@@ -310,7 +310,7 @@ test_invalid_b_flag(void)snprintf (prefix,sizeof (prefix),"--file-prefix=%s" , tmp);#endif -const char *blinval[][9 ] = { +const char *blinval[][5 ] = {
blinval[][6]?
app/test/test_eal_flags.c test_invalid_r_flag(void) · line 417
Quoted 9 lines
app/test/test_eal_flags.c +1
-1{prgname, prefix, mp_flag, "-b", "error"}, {prgname, prefix, mp_flag, "-b", "0:0:0"}, {prgname, prefix, mp_flag, "-b", "0:error:0.1"},@@ -414,7 +414,7 @@ test_invalid_r_flag(void)snprintf (prefix,sizeof (prefix),"--file-prefix=%s" , tmp);#endif -const char *rinval[][9 ] = { +const char *rinval[][5 ] = {
rinval[][4]?
Quoted 6 lines
app/test/test_eal_flags.c +0
-1{prgname, prefix, mp_flag, "-r", "error"}, {prgname, prefix, mp_flag, "-r", "0"}, {prgname, prefix, mp_flag, "-r", "-1"}, --1.8.3.1
Quoted 4 lines · Michael Santana Francisco
Quoted 1 line · David Marchand
Quoted 8 lines
Quoted 7 lines
Following removal of -c and -n options, the array should have been shrunk to avoid
launch_procto access unitialised strings.Fixes b4dbacdb1ad7 ("test/eal: set core mask/list config only in dedicated test")Fixes 501fa9a40298 ("test/eal: set memory channel config only in dedicated test")Signed-off-by David Marchand <[email protected]>Good patch, but is it just me or are you off by one in some places? see inline
The "funny" thing is that it went unnoticed, because the strdup happens after the test binary forked a child to start a dpdk process. This child segfaults, but the test code running in the parent just checks that starting this child failed (since it passed incorrect eal arguments).
Quoted 12 lines
Quoted 12 lines
--- app/test/test_eal_flags.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)app/test/test_eal_flags.c +0
-0@@ -244,7 +244,7 @@ test_whitelist_flag(void)snprintf (prefix,sizeof (prefix),"--file-prefix=%s" , tmp);#endif
Quoted 3 lines
app/test/test_eal_flags.c test_whitelist_flag(void) · line 247
Quoted 2 lines
app/test/test_eal_flags.c +1
-1-const char *wlinval[][11 ] = { +const char *wlinval[][7 ] = {Shoudln't this be wlinval[][6]?
I can see 7 elements in this array.
Quoted 10 lines
app/test/test_eal_flags.c test_invalid_b_flag(void) · line 313
Quoted 9 lines
app/test/test_eal_flags.c +1
-1{prgname, prefix, mp_flag, pci_whitelist, "error", "", ""}, {prgname, prefix, mp_flag,@@ -310,7 +310,7 @@ test_invalid_b_flag(void)snprintf (prefix,sizeof (prefix),"--file-prefix=%s" , tmp);#endif -const char *blinval[][9 ] = { +const char *blinval[][5 ] = {blinval[][6]?
5 elements.
Quoted 10 lines
app/test/test_eal_flags.c test_invalid_r_flag(void) · line 417
Quoted 9 lines
app/test/test_eal_flags.c +1
-1{prgname, prefix, mp_flag, "-b", "error"}, {prgname, prefix, mp_flag, "-b", "0:0:0"}, {prgname, prefix, mp_flag, "-b", "0:error:0.1"},@@ -414,7 +414,7 @@ test_invalid_r_flag(void)snprintf (prefix,sizeof (prefix),"--file-prefix=%s" , tmp);#endif -const char *rinval[][9 ] = { +const char *rinval[][5 ] = {rinval[][4]?
Idem.
Quoted 6 lines
Quoted 6 lines
app/test/test_eal_flags.c +0
-1{prgname, prefix, mp_flag, "-r", "error"}, {prgname, prefix, mp_flag, "-r", "0"}, {prgname, prefix, mp_flag, "-r", "-1"}, --1.8.3.1
Signature · 1 line
David Marchand
Michael Santana Francisco
Acked-byQuoted 35 lines · David Marchand
Quoted 4 lines · Michael Santana Francisco
Quoted 1 line · David Marchand
Quoted 8 lines
Quoted 7 lines
Following removal of -c and -n options, the array should have been shrunk to avoid
launch_procto access unitialised strings.Fixes b4dbacdb1ad7 ("test/eal: set core mask/list config only in dedicated test")Fixes 501fa9a40298 ("test/eal: set memory channel config only in dedicated test")Signed-off-by David Marchand <[email protected]>Good patch, but is it just me or are you off by one in some places? see inline
The "funny" thing is that it went unnoticed, because the strdup happens after the test binary forked a child to start a dpdk process. This child segfaults, but the test code running in the parent just checks that starting this child failed (since it passed incorrect eal arguments).
Quoted 12 lines
Quoted 12 lines
--- app/test/test_eal_flags.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)app/test/test_eal_flags.c +0
-0@@ -244,7 +244,7 @@ test_whitelist_flag(void)snprintf (prefix,sizeof (prefix),"--file-prefix=%s" , tmp);#endif
Quoted 5 lines
Quoted 3 lines
app/test/test_eal_flags.c test_whitelist_flag(void) · line 247
Quoted 2 lines
app/test/test_eal_flags.c +1
-1-const char *wlinval[][11 ] = { +const char *wlinval[][7 ] = {Shoudln't this be wlinval[][6]?
I can see 7 elements in this array.
My apologies, your patch was right from the start . I was counting the wrong thing
Quoted 37 lines
Quoted 11 lines
app/test/test_eal_flags.c test_invalid_b_flag(void) · line 313
Quoted 10 lines
app/test/test_eal_flags.c +1
-1{prgname, prefix, mp_flag, pci_whitelist, "error", "", ""}, {prgname, prefix, mp_flag,@@ -310,7 +310,7 @@ test_invalid_b_flag(void)snprintf (prefix,sizeof (prefix),"--file-prefix=%s" , tmp);#endif -const char *blinval[][9 ] = { +const char *blinval[][5 ] = {blinval[][6]?
5 elements.
Quoted 10 lines
app/test/test_eal_flags.c test_invalid_r_flag(void) · line 417
Quoted 9 lines
app/test/test_eal_flags.c +1
-1{prgname, prefix, mp_flag, "-b", "error"}, {prgname, prefix, mp_flag, "-b", "0:0:0"}, {prgname, prefix, mp_flag, "-b", "0:error:0.1"},@@ -414,7 +414,7 @@ test_invalid_r_flag(void)snprintf (prefix,sizeof (prefix),"--file-prefix=%s" , tmp);#endif -const char *rinval[][9 ] = { +const char *rinval[][5 ] = {rinval[][4]?
Idem.
Quoted 6 lines
Quoted 6 lines
app/test/test_eal_flags.c +0
-1{prgname, prefix, mp_flag, "-r", "error"}, {prgname, prefix, mp_flag, "-r", "0"}, {prgname, prefix, mp_flag, "-r", "-1"}, --1.8.3.1
--
David Marchand
Thomas Monjalon
AppliedQuoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Following removal of -c and -n options, the array should have been shrunk to avoid
launch_procto access unitialised strings.Fixes b4dbacdb1ad7 ("test/eal: set core mask/list config only in dedicated test")Fixes 501fa9a40298 ("test/eal: set memory channel config only in dedicated test")Signed-off-by David Marchand <[email protected]>Acked-by Michael Santana <[email protected]>
Applied, thanks.
About the title: "incorrect" after "fix" is always useless. I replaced it with "command" to give a bit more context about what these arrays are for.