diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-17 17:30:01 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-17 17:30:01 +0000 |
commit | b131b271a0d89b1ff04fd721530f424d0a15f0b2 (patch) | |
tree | 2f6450c7a7822e635c31acdfceaaec5f6c95d0de /libbb/read.c | |
parent | 7cdc54ff59697fe42048b06a3b4ed956bb7f0b3f (diff) | |
download | busybox-b131b271a0d89b1ff04fd721530f424d0a15f0b2.tar.gz |
start_stop_daemon: fix bug where any program name was "matching"
processes for which readlink(/proc/N/exe) fails
Diffstat (limited to 'libbb/read.c')
-rw-r--r-- | libbb/read.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libbb/read.c b/libbb/read.c index b3648b4d7..50e0354ad 100644 --- a/libbb/read.c +++ b/libbb/read.c @@ -118,16 +118,19 @@ void *xmalloc_open_read_close(const char *filename, size_t *sizep) char *buf; size_t size = sizep ? *sizep : INT_MAX; int fd = xopen(filename, O_RDONLY); - off_t len = xlseek(fd, 0, SEEK_END); + /* /proc/N/stat files report len 0 here */ + /* In order to make such files readable, we add small const */ + off_t len = xlseek(fd, 0, SEEK_END) + 256; xlseek(fd, 0, SEEK_SET); if (len > size) bb_error_msg_and_die("file '%s' is too big", filename); size = len; - buf = xmalloc(size+1); + buf = xmalloc(size + 1); size = read_close(fd, buf, size); if ((ssize_t)size < 0) bb_perror_msg_and_die("'%s'", filename); + xrealloc(buf, size + 1); buf[size] = '\0'; if (sizep) *sizep = size; return buf; |