aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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;
}
}