summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2010-11-04 22:47:16 +0800
committerSam Spilsbury <smspillaz@gmail.com>2010-11-04 22:47:16 +0800
commit46bc7db7d2b866763913f77c31c5cdd370acf9cc (patch)
treee5bf5a68de0a1fc80fe50aeb68141d61807ee043
parentb3bc6fcb8a12d8b5811b734621b6f3f6081bd592 (diff)
downloadcolorfilter-46bc7db7d2b866763913f77c31c5cdd370acf9cc.tar.gz
colorfilter-46bc7db7d2b866763913f77c31c5cdd370acf9cc.tar.bz2
Fix buffer overrun
-rw-r--r--src/parser.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index beaf66c..27d0f68 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -117,16 +117,18 @@ FragmentParser::programReadSource (const CompString &fname)
/* get length of file: */
fp.seekg (0, std::ios::end);
length = fp.tellg ();
+ length++;
fp.seekg (0, std::ios::beg);
/* allocate memory */
buffer = new char [length];
/* read data as a block: */
- fp.read (buffer, length);
+ fp.read (buffer, length - 1);
+ buffer[length - 1] = '\0';
fp.close ();
- data = CompString (buffer);
+ data = buffer;
delete[] buffer;