umovestr: fix short read bug

* util.c (umovestr): Check the right address.
* tests/umovestr.c: New file.
* tests/umovestr2.c: Likewise.
* tests/umovestr.expected: Likewise.
* tests/umovestr.test: New test.
* tests/umovestr2.test: Likewise.
* tests/Makefile.am (check_PROGRAMS): Add umovestr and umovestr2.
(TESTS): Add umovestr.test and umovestr2.test.
(EXTRA_DIST): Add umovestr.expected.
* tests/.gitignore: Add umovestr and umovestr2.

Reported-by: Josef T. Burger <bolo@cs.wisc.edu>
diff --git a/tests/umovestr2.c b/tests/umovestr2.c
new file mode 100644
index 0000000..a1ca9fd
--- /dev/null
+++ b/tests/umovestr2.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+int
+main(void)
+{
+	const size_t page_len = sysconf(_SC_PAGESIZE);
+	const size_t work_len = page_len * 2;
+	const size_t tail_len = work_len - 1;
+
+	void *p = mmap(NULL, page_len * 3, PROT_READ | PROT_WRITE,
+		       MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+	if (p == MAP_FAILED || mprotect(p + work_len, page_len, PROT_NONE))
+		return 77;
+
+	memset(p, 0, work_len);
+	char *addr = p + work_len - tail_len;
+	memset(addr, '0', tail_len - 1);
+
+	char *argv[] = { NULL };
+	char *envp[] = { addr, NULL };
+	execve("", argv, envp);
+
+	printf("execve\\(\"\", \\[\\], \\[\"%0*u\"\\]\\) = -1 .*\n",
+	       (int) tail_len - 1, 0);
+
+	return 0;
+}