File mawk-1.3.4-fix-regex-matching.patch of Package mawk.import5644

diff -urNp mawk-1.3.4.orig/files.c mawk-1.3.4/files.c
--- mawk-1.3.4.orig/files.c	2009-12-17 01:06:51.000000000 +0100
+++ mawk-1.3.4/files.c	2012-01-09 22:07:45.667127645 +0100
@@ -506,7 +506,7 @@ remove_from_child_list(int pid)
 int
 wait_for(int pid)
 {
-    int exit_status;
+    int exit_status = 0;
     struct child *p;
     int id;
 
diff -urNp mawk-1.3.4.orig/fin.c mawk-1.3.4/fin.c
--- mawk-1.3.4.orig/fin.c	2009-12-17 01:06:57.000000000 +0100
+++ mawk-1.3.4/fin.c	2012-01-09 22:07:45.667127645 +0100
@@ -317,7 +317,7 @@ FINgets(FIN * fin, unsigned *len_p)
 	unsigned rr;
 	unsigned amount = (unsigned) (fin->limit - p);
 
-	p = (char *) memcpy(fin->buff, p, r = (unsigned) (fin->limit - p));
+	p = (char *) memmove(fin->buff, p, r = (unsigned) (fin->limit - p));
 	q = p + r;
 	rr = fin->nbuffs * BUFFSZ - r;
 
diff -urNp mawk-1.3.4.orig/rexp3.c mawk-1.3.4/rexp3.c
--- mawk-1.3.4.orig/rexp3.c	2009-12-15 02:50:07.000000000 +0100
+++ mawk-1.3.4/rexp3.c	2012-01-09 22:07:45.668127668 +0100
@@ -149,7 +149,10 @@ REmatch(char *str,		/* string to test */
 	goto reswitch;
 
     case M_STR + U_ON + END_OFF:
-	if (!(s = str_str(s, str_len, m->s_data.str, m->s_len))) {
+	if (s >= str_end) {
+	    goto refill;
+	}
+	if (!(s = str_str(s, (unsigned) (str_end - s), m->s_data.str, m->s_len))) {
 	    goto refill;
 	}
 	if (s >= str + strlen(str)) {
@@ -229,6 +232,9 @@ REmatch(char *str,		/* string to test */
 		s++;
 	    }
 	}
+	if (s >= str_end) {
+	    goto refill;
+	}
 	s++;
 	push(m, s, ss, U_ON);
 	if (!ss) {