This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] elfclassify tool


* 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'.

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]