From b141b9b512f0faa01624bf384046439abc9b2850 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Tue, 31 Oct 2006 22:46:08 +0000 Subject: reads: fix bug 1078 --- libbb/read.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libbb/read.c') 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) 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; -- cgit v1.2.3