summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2001-12-06 01:29:00 +0000
committerBob Beck <beck@cvs.openbsd.org>2001-12-06 01:29:00 +0000
commitc3124afcb83409c06de2a74bb012a562e727052c (patch)
tree6e45b22023bd8a82cd64f506975b83d31c3194be
parent4a4f2f8c69d59986e2076826136cdb0b5f157d9c (diff)
Fix realloc in getline so we exit on failure - in this context it's silly
to try to continue and hold on to the same memory if we can't get memory to hold a control command. log and fail instead. (absurdity spotted by theo)
-rw-r--r--libexec/ftp-proxy/getline.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libexec/ftp-proxy/getline.c b/libexec/ftp-proxy/getline.c
index 4ed10e4a11a..f76f186d6ad 100644
--- a/libexec/ftp-proxy/getline.c
+++ b/libexec/ftp-proxy/getline.c
@@ -105,8 +105,10 @@ refill_buffer(register struct csiob *iobp)
iobp->io_buffer_size += 128;
tmp = realloc(iobp->io_buffer, iobp->io_buffer_size);
- if (tmp == NULL)
- return(0);
+ if (tmp == NULL) {
+ syslog(LOG_INFO, "Insufficient memory");
+ exit(EX_UNAVAILABLE);
+ }
iobp->io_buffer = tmp;
rqlen = iobp->io_buffer_size - iobp->io_buffer_len;
}
@@ -150,6 +152,8 @@ refill_buffer(register struct csiob *iobp)
*
* This code is derived from the getline routine found in the UC Berkeley
* ftpd code.
+ *
+ * thie
*/
int
@@ -256,8 +260,10 @@ telnet_getline(register struct csiob *iobp, struct csiob *telnet_passthrough)
iobp->line_buffer_size = 256 + ix - iobp->next_byte;
tmp = realloc(iobp->line_buffer,
iobp->line_buffer_size);
- if (tmp == NULL)
- return(0);
+ if (tmp == NULL) {
+ syslog(LOG_INFO, "Insufficient memory");
+ exit(EX_UNAVAILABLE);
+ }
iobp->line_buffer = tmp;
}