+2020-05-09 Ian Lance Taylor <iant@golang.org>
+
+ * read.c (backtrace_get_view): Support short read.
+
2020-05-09 Ian Lance Taylor <iant@golang.org>
* elf.c (elf_add): If debug sections are very large or far apart,
backtrace_error_callback error_callback,
void *data, struct backtrace_view *view)
{
- ssize_t got;
+ uint64_t got;
+ ssize_t r;
if ((uint64_t) (size_t) size != size)
{
view->data = view->base;
view->len = size;
- got = read (descriptor, view->base, size);
- if (got < 0)
+ got = 0;
+ while (got < size)
{
- error_callback (data, "read", errno);
- free (view->base);
- return 0;
+ r = read (descriptor, view->base, size - got);
+ if (r < 0)
+ {
+ error_callback (data, "read", errno);
+ free (view->base);
+ return 0;
+ }
+ if (r == 0)
+ break;
+ got += (uint64_t) r;
}
- if ((size_t) got < size)
+ if (got < size)
{
error_callback (data, "file too short", 0);
free (view->base);