Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/locate/code fool gcc with strncpy.



details:   https://anonhg.NetBSD.org/src/rev/0bd25a2789af
branches:  trunk
changeset: 845719:0bd25a2789af
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Oct 13 19:39:15 2019 +0000

description:
fool gcc with strncpy.

diffstat:

 usr.bin/locate/code/locate.code.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 0f7bfdf39642 -r 0bd25a2789af usr.bin/locate/code/locate.code.c
--- a/usr.bin/locate/code/locate.code.c Sun Oct 13 17:32:15 2019 +0000
+++ b/usr.bin/locate/code/locate.code.c Sun Oct 13 19:39:15 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locate.code.c,v 1.11 2011/09/04 20:28:40 joerg Exp $   */
+/*     $NetBSD: locate.code.c,v 1.12 2019/10/13 19:39:15 christos Exp $        */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)locate.code.c      8.4 (Berkeley) 5/4/95";
 #endif
-__RCSID("$NetBSD: locate.code.c,v 1.11 2011/09/04 20:28:40 joerg Exp $");
+__RCSID("$NetBSD: locate.code.c,v 1.12 2019/10/13 19:39:15 christos Exp $");
 #endif /* not lint */
 
 /*
@@ -119,7 +119,8 @@
                usage();
 
        /* First copy bigram array to stdout. */
-       strncpy(bigrams, argv[0], BGBUFSIZE + 1);
+       strncpy(bigrams, argv[0], BGBUFSIZE);
+       bigrams[BGBUFSIZE] = '\0';
        if (fwrite(bigrams, 1, BGBUFSIZE, stdout) != BGBUFSIZE)
                err(1, "stdout");
 



Home | Main Index | Thread Index | Old Index