reads: fix bug 1078
This commit is contained in:
parent
4126b1f5c6
commit
b141b9b512
@ -86,7 +86,8 @@ char *reads(int fd, char *buffer, size_t size)
|
|||||||
if (p) {
|
if (p) {
|
||||||
off_t offset;
|
off_t offset;
|
||||||
*p++ = '\0';
|
*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
|
// set fd position the right after the \n
|
||||||
if (offset && lseek(fd, offset, SEEK_CUR) == (off_t)-1)
|
if (offset && lseek(fd, offset, SEEK_CUR) == (off_t)-1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user