Re: [Patch v1 1/3] bugreport.c: replace strbuf_write_fd with write_in_full

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 19, 2020 at 11:04:43AM -0400, randall.s.becker@xxxxxxxxxx wrote:

> From: "Randall S. Becker" <rsbecker@xxxxxxxxxxxxx>
> 
> The strbuf_write_fd method did not provide checks for buffers larger
> than MAX_IO_SIZE. Replacing with write_in_full ensures the entire
> buffer will always be written to disk or report an error and die.

This also fixes problems with EINTR, etc.

> -	strbuf_write_fd(&buffer, report);
> +	if (write_in_full(report, buffer.buf, buffer.len) < 0) {
> +		die(_("couldn't write report contents '%s' to file '%s'"),
> +			buffer.buf, report_path.buf);
> +	}

I agree with the other comment not to bother reporting the contents. But
it is worth using die_errno() so we can see what happened. I.e.:

  die_errno(_("unable to write to %s"), report_path.buf);

would match our usual messages, and you'd get:

  unable to write to foo.out: No space left on device

or similar.

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux