diff options
author | Bill Nottingham <notting@redhat.com> | 2001-01-29 19:49:48 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2001-01-29 19:49:48 +0000 |
commit | dcaf2cc27fa136400a984db17a47eedd72dc3823 (patch) | |
tree | 0c295c0f284ee1731c3bd494e3e2c6337bf5a3ae /src | |
parent | ec31ccfeb558b3f4cf36022a3694008252d5e779 (diff) | |
download | initscripts-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')
-rw-r--r-- | src/minilogd.c | 19 |
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; } } |