diff options
| author | Wayne Davison <wayned@samba.org> | 2005-07-29 18:31:12 +0000 |
|---|---|---|
| committer | Wayne Davison <wayned@samba.org> | 2005-07-29 18:31:12 +0000 |
| commit | 33544bf422db889e33e746a3a758b7f6fe6254b1 (patch) | |
| tree | f4fcc9bc1b86fdaa9352d587bae9b0c53f12786b /io.c | |
| parent | 20accf4d06dfe020f6773a302b05491177c46ff3 (diff) | |
| download | android_external_rsync-33544bf422db889e33e746a3a758b7f6fe6254b1.tar.gz android_external_rsync-33544bf422db889e33e746a3a758b7f6fe6254b1.tar.bz2 android_external_rsync-33544bf422db889e33e746a3a758b7f6fe6254b1.zip | |
- Use BIGPATHBUFLEN for the length of several buffers.
- If io_printf() tries to overflow the buffer, die with
an error instead of sending a truncated buffer.
Diffstat (limited to 'io.c')
| -rw-r--r-- | io.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -728,11 +728,7 @@ static int readfd_unbuffered(int fd, char *buf, size_t len) static size_t iobuf_in_ndx; size_t msg_bytes; int tag, ret = 0; -#if MAXPATHLEN < 4096 - char line[4096+1024]; -#else - char line[MAXPATHLEN+1024]; -#endif + char line[BIGPATHBUFLEN]; if (!iobuf_in || fd != sock_f_in) return read_timeout(fd, buf, len); @@ -1118,7 +1114,7 @@ static void writefd_unbuffered(int fd,char *buf,size_t len) **/ static void mplex_write(enum msgcode code, char *buf, size_t len) { - char buffer[4096]; + char buffer[BIGPATHBUFLEN]; size_t n = len; SIVAL(buffer, 0, ((MPLEX_BASE + (int)code)<<24) + len); @@ -1313,7 +1309,7 @@ int read_line(int f, char *buf, size_t maxlen) void io_printf(int fd, const char *format, ...) { va_list ap; - char buf[1024]; + char buf[BIGPATHBUFLEN]; int len; va_start(ap, format); @@ -1323,6 +1319,11 @@ void io_printf(int fd, const char *format, ...) if (len < 0) exit_cleanup(RERR_STREAMIO); + if (len > (int)sizeof buf) { + rprintf(FERROR, "io_printf() was too long for the buffer.\n"); + exit_cleanup(RERR_STREAMIO); + } + write_sbuf(fd, buf); } |
