diff options
Diffstat (limited to 'libbb/read.c')
-rw-r--r-- | libbb/read.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libbb/read.c b/libbb/read.c index 1d31fb076..ba366cb97 100644 --- a/libbb/read.c +++ b/libbb/read.c | |||
@@ -212,7 +212,9 @@ void *xmalloc_open_read_close(const char *filename, size_t *sizep) | |||
212 | int fd; | 212 | int fd; |
213 | off_t len; | 213 | off_t len; |
214 | 214 | ||
215 | fd = xopen(filename, O_RDONLY); | 215 | fd = open(filename, O_RDONLY); |
216 | if (fd < 0) | ||
217 | return NULL; | ||
216 | /* /proc/N/stat files report len 0 here */ | 218 | /* /proc/N/stat files report len 0 here */ |
217 | /* In order to make such files readable, we add small const */ | 219 | /* In order to make such files readable, we add small const */ |
218 | len = xlseek(fd, 0, SEEK_END) | 0x3ff; /* + up to 1k */ | 220 | len = xlseek(fd, 0, SEEK_END) | 0x3ff; /* + up to 1k */ |
@@ -229,3 +231,11 @@ void *xmalloc_open_read_close(const char *filename, size_t *sizep) | |||
229 | *sizep = size; | 231 | *sizep = size; |
230 | return buf; | 232 | return buf; |
231 | } | 233 | } |
234 | |||
235 | void *xmalloc_xopen_read_close(const char *filename, size_t *sizep) | ||
236 | { | ||
237 | void *buf = xmalloc_open_read_close(filename, sizep); | ||
238 | if (!buf) | ||
239 | bb_perror_msg_and_die("can't read '%s'", filename); | ||
240 | return buf; | ||
241 | } | ||