diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-10-31 22:46:08 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-10-31 22:46:08 +0000 |
commit | 99e6f39f0f78f53743d57422152107542ee3cd33 (patch) | |
tree | 3a83675d2871e1e74168e2ffef9e9f4bed509b17 | |
parent | a0ce0a6f47f5f82c642c83e98d5ca3417316f4c4 (diff) | |
download | busybox-w32-99e6f39f0f78f53743d57422152107542ee3cd33.tar.gz busybox-w32-99e6f39f0f78f53743d57422152107542ee3cd33.tar.bz2 busybox-w32-99e6f39f0f78f53743d57422152107542ee3cd33.zip |
reads: fix bug 1078
git-svn-id: svn://busybox.net/trunk/busybox@16480 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | libbb/read.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libbb/read.c b/libbb/read.c index 1c2945f45..b3648b4d7 100644 --- a/libbb/read.c +++ b/libbb/read.c | |||
@@ -86,7 +86,8 @@ char *reads(int fd, char *buffer, size_t size) | |||
86 | if (p) { | 86 | if (p) { |
87 | off_t offset; | 87 | off_t offset; |
88 | *p++ = '\0'; | 88 | *p++ = '\0'; |
89 | offset = (p-buffer) - size; | 89 | // avoid incorrect (unsigned) widening |
90 | offset = (off_t)(p-buffer) - (off_t)size; | ||
90 | // set fd position the right after the \n | 91 | // set fd position the right after the \n |
91 | if (offset && lseek(fd, offset, SEEK_CUR) == (off_t)-1) | 92 | if (offset && lseek(fd, offset, SEEK_CUR) == (off_t)-1) |
92 | return NULL; | 93 | return NULL; |