blob: 23b33102b1b8c0eb6aa3c115e24a820f8f837a28 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
$NetBSD: patch-ba,v 1.2 2015/04/20 13:38:23 rodent Exp $
Bounds checking.
--- lib-src/portsmf/strparse.cpp.orig 2015-03-02 01:07:05.000000000 +0000
+++ lib-src/portsmf/strparse.cpp
@@ -19,8 +19,9 @@ char String_parse::peek()
}
-void String_parse::get_nonspace_quoted(string &field)
+void String_parse::get_nonspace_quoted(string &field, int flen)
{
+ char *ofield = field;
field.clear();
skip_space();
bool quoted = false;
@@ -29,7 +30,7 @@ void String_parse::get_nonspace_quoted(s
field.append(1, '"');
pos = pos + 1;
}
- while ((*str)[pos] && (quoted || !isspace((*str)[pos]))) {
+ while ((*str)[pos] && (quoted || !isspace((*str)[pos])) && (field - ofield) < (flen - 2)) {
if ((*str)[pos] == '"') {
if (quoted) {
field.append(1, '"');
|