summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-08-18 17:11:01 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-08-18 17:11:01 +0200
commit96071530ea85635cf87a6bf650b7f5ddbd219f44 (patch)
treec4223eed2389858bc3a5ca4f9efa12e1b277d3b3 /src
parentc7e57a5e1ab09f209afa0c92ac9894b79c523613 (diff)
downloadabrt-96071530ea85635cf87a6bf650b7f5ddbd219f44.tar.gz
abrt-96071530ea85635cf87a6bf650b7f5ddbd219f44.tar.xz
abrt-96071530ea85635cf87a6bf650b7f5ddbd219f44.zip
daemon: make text detection fail on any file >64k
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r--src/daemon/MiddleWare.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/daemon/MiddleWare.cpp b/src/daemon/MiddleWare.cpp
index bbb485f9..a0c6b477 100644
--- a/src/daemon/MiddleWare.cpp
+++ b/src/daemon/MiddleWare.cpp
@@ -68,6 +68,19 @@ static char* is_text_file(const char *name, ssize_t *sz)
if (fd < 0)
return NULL; /* it's not text (because it does not exist! :) */
+ /* Maybe 64k limit is small. But _some_ limit is necessary:
+ * fields declared "text" may end up in editing fields and such.
+ * We don't want to accidentally end up with 100meg text in a textbox!
+ * So, don't remove this. If you really need to, raise the limit.
+ */
+ off_t size = lseek(fd, 0, SEEK_END);
+ if (size < 0 || size > 64*1024)
+ {
+ close(fd);
+ return NULL; /* it's not a SMALL text */
+ }
+ lseek(fd, 0, SEEK_SET);
+
char *buf = (char*)xmalloc(*sz);
ssize_t r = *sz = full_read(fd, buf, *sz);
close(fd);