Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Feb 2012 22:07:09 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r231786 - stable/9/tools/regression/doat
Message-ID:  <201202152207.q1FM79Fu084119@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Wed Feb 15 22:07:09 2012
New Revision: 231786
URL: http://svn.freebsd.org/changeset/base/231786

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

Modified:
  stable/9/tools/regression/doat/doat.c
Directory Properties:
  stable/9/tools/regression/doat/   (props changed)

Modified: stable/9/tools/regression/doat/doat.c
==============================================================================
--- stable/9/tools/regression/doat/doat.c	Wed Feb 15 21:55:48 2012	(r231785)
+++ stable/9/tools/regression/doat/doat.c	Wed Feb 15 22:07:09 2012	(r231786)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202152207.q1FM79Fu084119>