diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2012-07-06 15:51:40 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2012-07-06 15:51:40 +0000 |
commit | 76b83c514f6b202659c8b600b20fe0e107f83f6f (patch) | |
tree | af36fda3bfca8aec4d85d31f156a90c6c1a56759 | |
parent | a6fb9c08a9ac65df98ca8829f43083feda19a6fe (diff) | |
download | gdb-76b83c514f6b202659c8b600b20fe0e107f83f6f.zip gdb-76b83c514f6b202659c8b600b20fe0e107f83f6f.tar.gz gdb-76b83c514f6b202659c8b600b20fe0e107f83f6f.tar.bz2 |
gdb/
PR 14321
* findcmd.c (parse_find_args): New variable pattern_buf_size_need.
Increase buffer sizes to 2x we need, not just 2x of the previous size.
gdb/testsuite/
PR 14321
* gdb.base/find.exp
(find int64_search_buf, +64/8*100, int64_search_buf): New test.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/findcmd.c | 8 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/find.exp | 3 |
4 files changed, 20 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 16e795c..5c434a0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2012-07-06 Jan Kratochvil <jan.kratochvil@redhat.com> + + PR 14321 + * findcmd.c (parse_find_args): New variable pattern_buf_size_need. + Increase buffer sizes to 2x we need, not just 2x of the previous size. + 2012-07-06 Tom Tromey <tromey@redhat.com> * c-exp.y (DOTDOTDOT): New token. diff --git a/gdb/findcmd.c b/gdb/findcmd.c index 3fce269..68184aa 100644 --- a/gdb/findcmd.c +++ b/gdb/findcmd.c @@ -170,6 +170,7 @@ parse_find_args (char *args, ULONGEST *max_countp, { LONGEST x; int val_bytes; + ULONGEST pattern_buf_size_need; while (isspace (*s)) ++s; @@ -179,12 +180,13 @@ parse_find_args (char *args, ULONGEST *max_countp, /* Keep it simple and assume size == 'g' when watching for when we need to grow the pattern buf. */ - if ((pattern_buf_end - pattern_buf + max (val_bytes, sizeof (int64_t))) - > pattern_buf_size) + pattern_buf_size_need = (pattern_buf_end - pattern_buf + + max (val_bytes, sizeof (int64_t))); + if (pattern_buf_size_need > pattern_buf_size) { size_t current_offset = pattern_buf_end - pattern_buf; - pattern_buf_size *= 2; + pattern_buf_size = pattern_buf_size_need * 2; pattern_buf = xrealloc (pattern_buf, pattern_buf_size); pattern_buf_end = pattern_buf + current_offset; } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index fdc921d..4301b03 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-07-06 Jan Kratochvil <jan.kratochvil@redhat.com> + + PR 14321 + * gdb.base/find.exp + (find int64_search_buf, +64/8*100, int64_search_buf): New test. + 2012-07-06 Tom Tromey <tromey@redhat.com> * gdb.base/whatis.exp: Add test. diff --git a/gdb/testsuite/gdb.base/find.exp b/gdb/testsuite/gdb.base/find.exp index ad54d65..5e41d97 100644 --- a/gdb/testsuite/gdb.base/find.exp +++ b/gdb/testsuite/gdb.base/find.exp @@ -182,3 +182,6 @@ if [isnative] { "${hex_number}${one_pattern_found}" \ "find pattern straddling chunk boundary" } + +# Check GDB buffer overflow. +gdb_test "find int64_search_buf, +64/8*100, int64_search_buf" " <int64_search_buf>\r\n1 pattern found\\." |