aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2>2007-06-13 20:12:28 +0000
committergotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2>2007-06-13 20:12:28 +0000
commitce70dda776eda1bc3405d606fcb8e72e95c0bab8 (patch)
treece3633377232bf431ffad08939fa32d4ef402cab
parente670adc7610af0dbf57e45cbfd62f2264d6c29fe (diff)
downloaddzen-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.h2
-rw-r--r--main.c5
2 files changed, 5 insertions, 2 deletions
diff --git a/dzen.h b/dzen.h
index ad98e70..be82e44 100644
--- a/dzen.h
+++ b/dzen.h
@@ -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 */
diff --git a/main.c b/main.c
index ae1782a..5986a3c 100644
--- a/main.c
+++ b/main.c
@@ -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;