public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/autopar_devel] libbacktrace: support short read
@ 2020-08-22 21:03 Giuliano Belinassi
0 siblings, 0 replies; only message in thread
From: Giuliano Belinassi @ 2020-08-22 21:03 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:0fd3481f9c499c486b3954d7bba6e5cc9f56b071
commit 0fd3481f9c499c486b3954d7bba6e5cc9f56b071
Author: Ian Lance Taylor <iant@golang.org>
Date: Sat Feb 15 18:13:28 2020 -0800
libbacktrace: support short read
* read.c (backtrace_get_view): Support short read.
Diff:
---
libbacktrace/ChangeLog | 4 ++++
libbacktrace/read.c | 22 +++++++++++++++-------
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog
index 277d7c01ff3..4b4f574fc75 100644
--- a/libbacktrace/ChangeLog
+++ b/libbacktrace/ChangeLog
@@ -1,3 +1,7 @@
+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,
diff --git a/libbacktrace/read.c b/libbacktrace/read.c
index 57e4701bbeb..1a6052bf613 100644
--- a/libbacktrace/read.c
+++ b/libbacktrace/read.c
@@ -50,7 +50,8 @@ backtrace_get_view (struct backtrace_state *state, int descriptor,
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)
{
@@ -70,15 +71,22 @@ backtrace_get_view (struct backtrace_state *state, int descriptor,
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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-22 21:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 21:03 [gcc/devel/autopar_devel] libbacktrace: support short read Giuliano Belinassi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).