On Mon, Jul 29, 2019 at 11:16:31AM +0200, Florian Weimer wrote: > * Mark Wielaard: > > > +/* Called to process standard input if flag_stdin is not no_stdin. */ > > +static void > > +process_stdin (int *status) > > +{ > > + char delim; > > + if (flag_stdin == do_stdin0) > > + delim = '\0'; > > + else > > + delim = '\n'; > > + > > + char *buffer = NULL; > > + size_t buffer_size = 0; > > + while (true) > > + { > > + ssize_t ret = getdelim (&buffer, &buffer_size, delim, stdin); > > + if (ferror (stdin)) > > + { > > + current_path = NULL; > > + issue (errno, N_("reading from standard input")); > > + break; > > + } > > + if (feof (stdin)) > > + break; > > + if (ret < 0) > > + abort (); /* Cannot happen due to error checks above. */ > > + if (delim != '\0' && ret > 0) > > + buffer[ret - 1] = '\0'; > > I think this can overwrite the last character of the last line if the > file does not end with '\n'.
I see. "The buffer is null-terminated and includes the newline character, if one was found." So the test should be: diff --git a/src/elfclassify.c b/src/elfclassify.c index ebd42c1d5..b17d14d45 100644 --- a/src/elfclassify.c +++ b/src/elfclassify.c @@ -862,7 +862,7 @@ process_stdin (int *status) break; if (ret < 0) abort (); /* Cannot happen due to error checks above. */ - if (delim != '\0' && ret > 0) + if (delim != '\0' && ret > 0 && buffer[ret - 1] == '\n') buffer[ret - 1] = '\0'; current_path = buffer; process_current_path (status); Thanks, Mark