summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko2006-10-31 22:46:08 +0000
committerDenis Vlasenko2006-10-31 22:46:08 +0000
commitb141b9b512f0faa01624bf384046439abc9b2850 (patch)
tree3a83675d2871e1e74168e2ffef9e9f4bed509b17
parent4126b1f5c6983b7c2dd4f92d635ab762d861c2d6 (diff)
downloadbusybox-b141b9b512f0faa01624bf384046439abc9b2850.zip
busybox-b141b9b512f0faa01624bf384046439abc9b2850.tar.gz
reads: fix bug 1078
-rw-r--r--libbb/read.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libbb/read.c b/libbb/read.c
index 1c2945f..b3648b4 100644
--- a/libbb/read.c
+++ b/libbb/read.c
@@ -86,7 +86,8 @@ char *reads(int fd, char *buffer, size_t size)
if (p) {
off_t offset;
*p++ = '\0';
- offset = (p-buffer) - size;
+ // avoid incorrect (unsigned) widening
+ offset = (off_t)(p-buffer) - (off_t)size;
// set fd position the right after the \n
if (offset && lseek(fd, offset, SEEK_CUR) == (off_t)-1)
return NULL;