Source-Changes-HG archive

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

[src/trunk]: src/games/tetris avoid uninit memory and use memmove vs strncpy ...



details:   https://anonhg.NetBSD.org/src/rev/57119058f2c2
branches:  trunk
changeset: 943600:57119058f2c2
user:      mrg <mrg%NetBSD.org@localhost>
date:      Mon Sep 07 00:31:11 2020 +0000

description:
avoid uninit memory and use memmove vs strncpy for a will be
truncated on purpose string.

diffstat:

 games/tetris/scores.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r e9d5bb6ce729 -r 57119058f2c2 games/tetris/scores.c
--- a/games/tetris/scores.c     Mon Sep 07 00:29:14 2020 +0000
+++ b/games/tetris/scores.c     Mon Sep 07 00:31:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scores.c,v 1.24 2018/06/24 12:55:36 mrg Exp $  */
+/*     $NetBSD: scores.c,v 1.25 2020/09/07 00:31:11 mrg Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -599,7 +599,7 @@
 {
 #ifdef ALLOW_SCORE_UPDATES
        struct highscore_header header;
-       struct highscore_ondisk buf[MAXHISCORES];
+       struct highscore_ondisk buf[MAXHISCORES] = {0};
        int i;
 
        if (sd == -1) {
@@ -611,7 +611,7 @@
        header.hsh_version = HSH_VERSION;
 
        for (i=0; i<nscores; i++) {
-               strncpy(buf[i].hso_name, scores[i].hs_name,
+               memcpy(buf[i].hso_name, scores[i].hs_name,
                        sizeof(buf[i].hso_name));
                buf[i].hso_score = scores[i].hs_score;
                buf[i].hso_level = scores[i].hs_level;



Home | Main Index | Thread Index | Old Index