From owner-svn-src-all@FreeBSD.ORG Tue Oct 18 22:51:40 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8D3AC106566B; Tue, 18 Oct 2011 22:51:40 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7CA738FC14; Tue, 18 Oct 2011 22:51:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p9IMpecr093636; Tue, 18 Oct 2011 22:51:40 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p9IMpelI093634; Tue, 18 Oct 2011 22:51:40 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201110182251.p9IMpelI093634@svn.freebsd.org> From: Jilles Tjoelker Date: Tue, 18 Oct 2011 22:51:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226523 - head/tools/regression/doat X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Oct 2011 22:51:40 -0000 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);