summaryrefslogtreecommitdiffstats
path: root/tools/regression/doat
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-10-18 22:51:40 +0000
committerjilles <jilles@FreeBSD.org>2011-10-18 22:51:40 +0000
commit8ee3860fbec0449fccf20bd41aac01e1429bccca (patch)
tree91bfd53e32bd8c39be1f8364944dc33437333a85 /tools/regression/doat
parent081cdfe9e8b89797fda367f5995e951143c640c1 (diff)
downloadFreeBSD-src-8ee3860fbec0449fccf20bd41aac01e1429bccca.zip
FreeBSD-src-8ee3860fbec0449fccf20bd41aac01e1429bccca.tar.gz
Fix some memory errors in *at() regression tests.
Diffstat (limited to 'tools/regression/doat')
-rw-r--r--tools/regression/doat/doat.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/tools/regression/doat/doat.c b/tools/regression/doat/doat.c
index f5ac795..d71648d 100644
--- a/tools/regression/doat/doat.c
+++ b/tools/regression/doat/doat.c
@@ -103,8 +103,9 @@ setup(void)
{
int i, error;
struct stat sb;
+ size_t len;
- tests = calloc(NUM_OF_TESTS, sizeof(struct test));
+ tests = calloc(NUM_OF_TESTS + 1, sizeof(struct test));
if (tests == NULL) {
perror("");
exit(0);
@@ -116,14 +117,16 @@ setup(void)
exit(0);
}
- absolute_path = realloc(absolute_path, strlen(absolute_path) + 5);
+ len = strlen(absolute_path);
+ absolute_path = realloc(absolute_path,
+ len + 1 + strlen(relative_path) + 1);
if (absolute_path == NULL) {
perror("realloc");
exit(0);
}
- absolute_path[strlen(absolute_path)] = '/';
- strcpy(absolute_path + strlen(absolute_path), relative_path);
+ absolute_path[len] = '/';
+ strcpy(absolute_path + len + 1, relative_path);
absolute_file = malloc(strlen(absolute_path) + 1 + strlen(file));
bzero(absolute_file, strlen(absolute_path) + 1 + strlen(file));
@@ -145,7 +148,7 @@ setup(void)
relative_file[strlen(relative_file)] = '/';
strcpy(relative_file + strlen(relative_path), file);
- error = mkdir(relative_path, 666);
+ error = mkdir(relative_path, 0700);
dir_exist = (errno == EEXIST);
if (error && errno != EEXIST) {
perror("tmp");
@@ -154,7 +157,7 @@ setup(void)
error = stat("tmp/foo", &sb);
file_exist = (errno != ENOENT);
- i = open("tmp/foo", O_RDONLY | O_CREAT);
+ i = open("tmp/foo", O_RDONLY | O_CREAT, 0666);
if (i == -1) {
perror("foo");
exit(0);
OpenPOWER on IntegriCloud