commit 1d5afc189fffffaa28ff42b6e4130f812a3b9204
parent 23243f568782339b16ca1e7c7eea78567b976b97
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Mon, 20 Jul 2026 09:00:53 +0200
fix unbounded read in test
Diffstat:
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/testing/testing_api_cmd_system_start.c b/src/testing/testing_api_cmd_system_start.c
@@ -161,15 +161,19 @@ read_stdout (void *cls)
"Child closed stdout\n");
return;
}
- GNUNET_buffer_write (&as->ibuf, buf, ret);
+ GNUNET_buffer_write (&as->ibuf,
+ buf,
+ ret);
if ( (0 == strncmp (as->ibuf.mem,
READY_MARKER,
strlen (READY_MARKER))) &&
- (NULL != (testroot = strchr (as->ibuf.mem,
- '\n'))) )
+ (NULL != (testroot = memchr (as->ibuf.mem,
+ '\n',
+ as->ibuf.position))) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Got test root %s\n",
+ "Got test root %.*s\n",
+ (int) (as->ibuf.position - (testroot - as->ibuf.mem)),
testroot);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Taler system UP\n");
@@ -177,9 +181,10 @@ read_stdout (void *cls)
TALER_TESTING_interpreter_next (as->is);
return;
}
- if (NULL != strchr (as->ibuf.mem,
- '\n') ||
- as->ibuf.position > 4096)
+ if ( (NULL != memchr (as->ibuf.mem,
+ '\n',
+ as->ibuf.position)) ||
+ (as->ibuf.position > 4096) )
{
TALER_TESTING_interpreter_fail (as->is);
/* Only commands are allowed! */