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 | |
| parent | 7cdc54ff59697fe42048b06a3b4ed956bb7f0b3f (diff) | |
| download | busybox-w32-b131b271a0d89b1ff04fd721530f424d0a15f0b2.tar.gz busybox-w32-b131b271a0d89b1ff04fd721530f424d0a15f0b2.tar.bz2 busybox-w32-b131b271a0d89b1ff04fd721530f424d0a15f0b2.zip | |
start_stop_daemon: fix bug where any program name was "matching"
processes for which readlink(/proc/N/exe) fails
Diffstat (limited to 'libbb')
| -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) | |||
| 118 | char *buf; | 118 | char *buf; |
| 119 | size_t size = sizep ? *sizep : INT_MAX; | 119 | size_t size = sizep ? *sizep : INT_MAX; |
| 120 | int fd = xopen(filename, O_RDONLY); | 120 | int fd = xopen(filename, O_RDONLY); |
| 121 | off_t len = xlseek(fd, 0, SEEK_END); | 121 | /* /proc/N/stat files report len 0 here */ |
| 122 | /* In order to make such files readable, we add small const */ | ||
| 123 | off_t len = xlseek(fd, 0, SEEK_END) + 256; | ||
| 122 | xlseek(fd, 0, SEEK_SET); | 124 | xlseek(fd, 0, SEEK_SET); |
| 123 | 125 | ||
| 124 | if (len > size) | 126 | if (len > size) |
| 125 | bb_error_msg_and_die("file '%s' is too big", filename); | 127 | bb_error_msg_and_die("file '%s' is too big", filename); |
| 126 | size = len; | 128 | size = len; |
| 127 | buf = xmalloc(size+1); | 129 | buf = xmalloc(size + 1); |
| 128 | size = read_close(fd, buf, size); | 130 | size = read_close(fd, buf, size); |
| 129 | if ((ssize_t)size < 0) | 131 | if ((ssize_t)size < 0) |
| 130 | bb_perror_msg_and_die("'%s'", filename); | 132 | bb_perror_msg_and_die("'%s'", filename); |
| 133 | xrealloc(buf, size + 1); | ||
| 131 | buf[size] = '\0'; | 134 | buf[size] = '\0'; |
| 132 | if (sizep) *sizep = size; | 135 | if (sizep) *sizep = size; |
| 133 | return buf; | 136 | return buf; |
