diff options
| author | tgoodwin <tgoodwin> | 1998-02-05 14:50:14 +0000 |
|---|---|---|
| committer | Toby Goodwin <toby@paccrat.org> | 2015-05-16 21:23:02 +0100 |
| commit | 61f3dc4ae75009ba3e8638a7fb7767cdb92c598c (patch) | |
| tree | 5c12b2d68a405c22d2cfd500f371e4ee7ee4c001 | |
| parent | 784e5340c6b56ed2495eb5debe06ee43f9c2ddb3 (diff) | |
avoid longjmp clobber
| -rw-r--r-- | utils.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -66,16 +66,21 @@ extern bool isabsolute(char *path) { } /* signal-safe read and write (for BSD slow devices). writeall also allows partial writes */ +static char *safe_buf; +static size_t safe_remain; extern void writeall(int fd, char *buf, size_t remain) { int i; - for (i = 0; remain > 0; buf += i, remain -= i) { + + safe_buf = buf; + safe_remain = remain; + for (i = 0; safe_remain > 0; buf += i, safe_remain -= i) { interrupt_happened = FALSE; if (!setjmp(slowbuf.j)) { slow = TRUE; if (interrupt_happened) break; - else if ((i = write(fd, buf, remain)) <= 0) + else if ((i = write(fd, safe_buf, safe_remain)) <= 0) break; /* abort silently on errors in write() */ } else break; |