diff options
author | gotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2> | 2007-06-13 20:12:28 +0000 |
---|---|---|
committer | gotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2> | 2007-06-13 20:12:28 +0000 |
commit | ce70dda776eda1bc3405d606fcb8e72e95c0bab8 (patch) | |
tree | ce3633377232bf431ffad08939fa32d4ef402cab | |
parent | e670adc7610af0dbf57e45cbfd62f2264d6c29fe (diff) | |
download | dzen-ce70dda776eda1bc3405d606fcb8e72e95c0bab8.tar.gz dzen-ce70dda776eda1bc3405d606fcb8e72e95c0bab8.zip |
check for MAX_LINE_LEN in main.c:chomp to not overflow the buffer
git-svn-id: http://dzen.googlecode.com/svn/trunk@90 f2baff5b-bf2c-0410-a398-912abdc3d8b2
-rw-r--r-- | dzen.h | 2 | ||||
-rw-r--r-- | main.c | 5 |
2 files changed, 5 insertions, 2 deletions
@@ -96,7 +96,7 @@ struct DZEN { Bool ispersistent; Bool tsupdate; unsigned long timeout; - int cur_line; + long cur_line; int ret_val; /* should always be 0 if DZEN_XINERAMA not defined */ @@ -98,7 +98,7 @@ chomp(char *inbuf, char *outbuf, int start, int len) { free(rem); rem = NULL; } - while(off < len) { + while((off < len) && (off < MAX_LINE_LEN)) { if(inbuf[off] != '\n') { outbuf[i++] = inbuf[off++]; } else if(inbuf[off] == '\n') { @@ -107,6 +107,9 @@ chomp(char *inbuf, char *outbuf, int start, int len) { } } + if(off >= MAX_LINE_LEN) + return 0; + outbuf[i] = '\0'; rem = estrdup(outbuf); return 0; |