aboutsummaryrefslogtreecommitdiffstats
path: root/src/minilogd.c
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2001-01-29 19:49:48 +0000
committerBill Nottingham <notting@redhat.com>2001-01-29 19:49:48 +0000
commitdcaf2cc27fa136400a984db17a47eedd72dc3823 (patch)
tree0c295c0f284ee1731c3bd494e3e2c6337bf5a3ae /src/minilogd.c
parentec31ccfeb558b3f4cf36022a3694008252d5e779 (diff)
downloadinitscripts-dcaf2cc27fa136400a984db17a47eedd72dc3823.tar
initscripts-dcaf2cc27fa136400a984db17a47eedd72dc3823.tar.gz
initscripts-dcaf2cc27fa136400a984db17a47eedd72dc3823.tar.bz2
initscripts-dcaf2cc27fa136400a984db17a47eedd72dc3823.tar.xz
initscripts-dcaf2cc27fa136400a984db17a47eedd72dc3823.zip
add an upper bound on how much stuff we'll keep in memory
Diffstat (limited to 'src/minilogd.c')
-rw-r--r--src/minilogd.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/minilogd.c b/src/minilogd.c
index aba5e7c5..7fa2e586 100644
--- a/src/minilogd.c
+++ b/src/minilogd.c
@@ -95,18 +95,19 @@ void runDaemon(int sock) {
message = calloc(8192,sizeof(char));
recvsock = accept(sock,(struct sockaddr *) &addr, &addrlen);
len = read(recvsock,message,8192);
- if (buffer)
- buffer = realloc(buffer,(buflines+1)*sizeof(char *));
- else
- buffer = malloc(sizeof(char *));
+ close(recvsock);
if (len>0) {
- message[strlen(message)]='\n';
- buffer[buflines]=message;
- buflines++;
- close(recvsock);
+ if (buflines < 200000) {
+ if (buffer)
+ buffer = realloc(buffer,(buflines+1)*sizeof(char *));
+ else
+ buffer = malloc(sizeof(char *));
+ message[strlen(message)]='\n';
+ buffer[buflines]=message;
+ buflines++;
+ }
}
else {
- close(recvsock);
recvsock=-1;
}
}