Module Name: src Committed By: dholland Date: Sun Aug 9 00:34:21 UTC 2020
Modified Files: src/bin/csh: dir.c lex.c parse.c Log Message: Use the right size for several calloc calls. When allocating for a Char **, it should use sizeof(Char *), not sizeof(Char **). This doesn't actually affect the results except on DS9000 though :-) To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/bin/csh/dir.c cvs rdiff -u -r1.35 -r1.36 src/bin/csh/lex.c cvs rdiff -u -r1.20 -r1.21 src/bin/csh/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/csh/dir.c diff -u src/bin/csh/dir.c:1.34 src/bin/csh/dir.c:1.35 --- src/bin/csh/dir.c:1.34 Sun Aug 9 00:22:53 2020 +++ src/bin/csh/dir.c Sun Aug 9 00:34:21 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.34 2020/08/09 00:22:53 dholland Exp $ */ +/* $NetBSD: dir.c,v 1.35 2020/08/09 00:34:21 dholland Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dir.c,v 1.34 2020/08/09 00:22:53 dholland Exp $"); +__RCSID("$NetBSD: dir.c,v 1.35 2020/08/09 00:34:21 dholland Exp $"); #endif #endif /* not lint */ @@ -147,7 +147,7 @@ dset(Char *dp) * other junk characters glob will fail. */ - vec = xmalloc((size_t)(2 * sizeof(Char **))); + vec = xmalloc(2 * sizeof(*vec)); vec[0] = Strsave(dp); vec[1] = 0; setq(STRcwd, vec, &shvhed); Index: src/bin/csh/lex.c diff -u src/bin/csh/lex.c:1.35 src/bin/csh/lex.c:1.36 --- src/bin/csh/lex.c:1.35 Sun Aug 9 00:22:53 2020 +++ src/bin/csh/lex.c Sun Aug 9 00:34:21 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.35 2020/08/09 00:22:53 dholland Exp $ */ +/* $NetBSD: lex.c,v 1.36 2020/08/09 00:34:21 dholland Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: lex.c,v 1.35 2020/08/09 00:22:53 dholland Exp $"); +__RCSID("$NetBSD: lex.c,v 1.36 2020/08/09 00:34:21 dholland Exp $"); #endif #endif /* not lint */ @@ -1453,7 +1453,8 @@ again: if (buf >= fblocks) { Char **nfbuf; - nfbuf = xcalloc((size_t) (fblocks + 2), sizeof(char **)); + /* XXX the cast is needed because fblocks is signed */ + nfbuf = xcalloc((size_t)(fblocks + 2), sizeof(*nfbuf)); if (fbuf) { (void)blkcpy(nfbuf, fbuf); free(fbuf); @@ -1623,7 +1624,7 @@ settell(void) return; if (lseek(SHIN, (off_t) 0, SEEK_CUR) < 0 || errno == ESPIPE) return; - fbuf = xcalloc(2, sizeof(Char **)); + fbuf = xcalloc(2, sizeof(*fbuf)); fblocks = 1; fbuf[0] = xcalloc(BUFSIZE, sizeof(Char)); fseekp = fbobp = feobp = lseek(SHIN, (off_t) 0, SEEK_CUR); Index: src/bin/csh/parse.c diff -u src/bin/csh/parse.c:1.20 src/bin/csh/parse.c:1.21 --- src/bin/csh/parse.c:1.20 Sun Aug 9 00:22:53 2020 +++ src/bin/csh/parse.c Sun Aug 9 00:34:21 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.20 2020/08/09 00:22:53 dholland Exp $ */ +/* $NetBSD: parse.c,v 1.21 2020/08/09 00:34:21 dholland Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: parse.c,v 1.20 2020/08/09 00:22:53 dholland Exp $"); +__RCSID("$NetBSD: parse.c,v 1.21 2020/08/09 00:34:21 dholland Exp $"); #endif #endif /* not lint */ @@ -509,7 +509,8 @@ again: if (n < 0) n = 0; t = xcalloc(1, sizeof(*t)); - av = xcalloc((size_t)(n + 1), sizeof(Char **)); + /* XXX the cast is needed because n is signed */ + av = xcalloc((size_t)(n + 1), sizeof(*av)); t->t_dcom = av; n = 0; if (p2->word[0] == ')')