]> git.pld-linux.org Git - packages/gawk.git/blob - gawk-3.1.5-mbread.patch
- patches from fedora
[packages/gawk.git] / gawk-3.1.5-mbread.patch
1
2  Date: Mon, 18 Dec 2006 18:38:13 +0300
3  From: "Dmitry V. Levin" <ldv@altlinux.org>
4  Subject: gawk: do_match() invalid read
5  To: bug-gawk@gnu.org
6
7  Due to missing mounds check, do_match() may do invalid read in multibyte
8  locales:
9
10  $ printf '\n\n' |env -i gawk '{print match(""," *")}'
11  1
12  1
13  $ printf '\n\n' |env -i LC_ALL=3Dru_RU.UTF-8 gawk '{print match(""," *")}'
14  -1208299079
15  134843273
16
17  As you see, match() output in multibyte locale is wrong; valgrind reports
18  about "Invalid read of size 4".
19
20
21 --- gawk-3.1.5/builtin.c.mbread 2007-01-12 13:23:55.000000000 +0100
22 +++ gawk-3.1.5/builtin.c        2007-01-12 13:24:41.000000000 +0100
23 @@ -2020,7 +2020,7 @@
24  
25                 rlength = REEND(rp, t1->stptr) - RESTART(rp, t1->stptr);        /* byte length */
26  #ifdef MBS_SUPPORT
27 -               if (gawk_mb_cur_max > 1) {
28 +               if (rlength > 0 && gawk_mb_cur_max > 1) {
29                         t1 = str2wstr(t1, & wc_indices);
30                         rlength = wc_indices[rstart + rlength - 1] - wc_indices[rstart] + 1;
31                         rstart = wc_indices[rstart];
32 @@ -2046,7 +2046,7 @@
33                                         subpat_start = s;
34                                         subpat_len = len = SUBPATEND(rp, t1->stptr, ii) - s;
35  #ifdef MBS_SUPPORT
36 -                                       if (gawk_mb_cur_max > 1) {
37 +                                       if (len > 0 && gawk_mb_cur_max > 1) {
38                                                 subpat_start = wc_indices[s];
39                                                 subpat_len = wc_indices[s + len - 1] - subpat_start + 1;
40                                         }
This page took 0.032874 seconds and 3 git commands to generate.