library: avoid SEGV if file2str should read zero bytes
When utility buffers were introduced for file2str read
requests, a subtle change was inadvertently introduced
such that a read of zero no longer returns a -1 value.
This commit ensures that zero bytes read returns a -1.
And although the solution differs from a merge request
submitted by sergey.senozhatsky@gmail.com, a thank you
is offered for revealing this potential abend problem.
References(s):
commit a45dace4b8
http://gitorious.org/procps/procps/merge_requests/11
Signed-off-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Craig Small <csmall@enc.com.au>
This commit is contained in:
parent
6d605f521c
commit
526bc5dfa9
@ -555,6 +555,7 @@ static int file2str(const char *directory, const char *what, struct utlbuf_s *ub
|
|||||||
};
|
};
|
||||||
ub->buf[tot_read] = '\0';
|
ub->buf[tot_read] = '\0';
|
||||||
close(fd);
|
close(fd);
|
||||||
|
if (unlikely(tot_read < 1)) return -1;
|
||||||
return tot_read;
|
return tot_read;
|
||||||
#undef readMAX
|
#undef readMAX
|
||||||
#undef buffMIN
|
#undef buffMIN
|
||||||
|
Loading…
Reference in New Issue
Block a user