I changed the definition of discardBuff to char discardBuff[100]{};
So that every element will be initialized to \0. This function is only used in TraceReaderLogQEMU.cc, and the values that are passed in are #define QEMU_LOG_IN_KEY "IN: " #define QEMU_LOG_SECTION_END "----------------" Neither are close to going over the size of discardBuff, but I can add a check and return false if it does happen to go over that length. -----Original Message----- From: Chris Johns <chr...@rtems.org> Sent: Tuesday, September 21, 2021 6:16 PM To: Ryan Long <ryan.l...@oarcorp.com>; devel@rtems.org Subject: Re: [PATCH rtems-tools v1 4/7] TraceReaderLogQEMU.cc: Fix formatting On 22/9/21 2:45 am, Ryan Long wrote: > --- > tester/covoar/TraceReaderLogQEMU.cc | 25 +++++++++++++------------ > 1 file changed, 13 insertions(+), 12 deletions(-) > > diff --git a/tester/covoar/TraceReaderLogQEMU.cc > b/tester/covoar/TraceReaderLogQEMU.cc > index c303d08..91ed5c7 100644 > --- a/tester/covoar/TraceReaderLogQEMU.cc > +++ b/tester/covoar/TraceReaderLogQEMU.cc > @@ -53,8 +53,8 @@ > > bool ReadUntilFound( std::ifstream& file, const char* line ) { > - char discardBuff[100]; > - size_t len = strlen( line ); > + char discardBuff[100]; 100 bytes on the stack and not initialised ... > + size_t len = strlen( line );> > do { > file.read( discardBuff, 99 ); Read one less than the buffer so index 99 is still not initialised ... > @@ -62,9 +62,11 @@ bool ReadUntilFound( std::ifstream& file, const char* line > ) > return false; > } > > - if ( strncmp( discardBuff, line, len ) == 0 ) > + if ( strncmp( discardBuff, line, len ) == 0 ) { Making a call that assumes index 99 is '\0'! Does the discard buffer need to be memset to 0? What if the length of line is greater than 100? Is that a valid find and so a partial match is OK? Do the lengths need to match? Chris _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel