aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-05-15 23:23:23 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-05-15 23:23:23 +0200
commit071ede1e5de784820f39c2546000c08d74b12f6d (patch)
tree4ff68f19cafbcf5acbd67691bd80c3014d1ecdff
parentc15f40c3e7bfeae1b616c53a574308c2df707b3d (diff)
downloadbusybox-w32-071ede1e5de784820f39c2546000c08d74b12f6d.tar.gz
busybox-w32-071ede1e5de784820f39c2546000c08d74b12f6d.tar.bz2
busybox-w32-071ede1e5de784820f39c2546000c08d74b12f6d.zip
xmalloc_[open_]read[_close]: do not ignore xrealloc return value
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--include/libbb.h6
-rw-r--r--libbb/read.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 128aa9207..bae7efb00 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -965,6 +965,12 @@ enum {
965 /* How long the longest ESC sequence we know? */ 965 /* How long the longest ESC sequence we know? */
966 KEYCODE_BUFFER_SIZE = 4 966 KEYCODE_BUFFER_SIZE = 4
967}; 967};
968/* Note: fd may be in blocking or non-blocking mode, both make sense.
969 * For one, less uses non-blocking mode.
970 * Only the first read syscall inside read_key may block indefinitely
971 * (unless fd is in non-blocking mode),
972 * subsequent reads will time out after a few milliseconds.
973 */
968int read_key(int fd, smalluint *nbuffered, char *buffer) FAST_FUNC; 974int read_key(int fd, smalluint *nbuffered, char *buffer) FAST_FUNC;
969 975
970 976
diff --git a/libbb/read.c b/libbb/read.c
index a0c0cc64a..b58982b32 100644
--- a/libbb/read.c
+++ b/libbb/read.c
@@ -229,7 +229,7 @@ void* FAST_FUNC xmalloc_read(int fd, size_t *maxsz_p)
229 if (size > 64*1024) 229 if (size > 64*1024)
230 size = 64*1024; 230 size = 64*1024;
231 } 231 }
232 xrealloc(buf, total + 1); 232 buf = xrealloc(buf, total + 1);
233 buf[total] = '\0'; 233 buf[total] = '\0';
234 234
235 if (maxsz_p) 235 if (maxsz_p)
@@ -273,7 +273,7 @@ void* FAST_FUNC xmalloc_open_read_close(const char *filename, size_t *maxsz_p)
273 free(buf); 273 free(buf);
274 return NULL; 274 return NULL;
275 } 275 }
276 xrealloc(buf, size + 1); 276 buf = xrealloc(buf, size + 1);
277 buf[size] = '\0'; 277 buf[size] = '\0';
278 278
279 if (maxsz_p) 279 if (maxsz_p)