Author: jilles
Date: Tue Oct 18 22:51:40 2011
New Revision: 226523
URL: http://svn.freebsd.org/changeset/base/226523

Log:
  Fix some memory errors in *at() regression tests.

Modified:
  head/tools/regression/doat/doat.c

Modified: head/tools/regression/doat/doat.c
==============================================================================
--- head/tools/regression/doat/doat.c   Tue Oct 18 20:16:02 2011        
(r226522)
+++ head/tools/regression/doat/doat.c   Tue Oct 18 22:51:40 2011        
(r226523)
@@ -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);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to