diff options
author | mrg <mrg@NetBSD.org> | 2020-09-07 00:31:11 +0000 |
---|---|---|
committer | mrg <mrg@NetBSD.org> | 2020-09-07 00:31:11 +0000 |
commit | 36303db1c8b4eb1d4def70b89273c5937763a9f3 (patch) | |
tree | 4a66643134f4619d94d27c86a67b91a63aa54eb9 | |
parent | c2232c803a2e3124372cf4ce0407ef660e2560a0 (diff) | |
download | bsdgames-darwin-36303db1c8b4eb1d4def70b89273c5937763a9f3.tar.gz bsdgames-darwin-36303db1c8b4eb1d4def70b89273c5937763a9f3.tar.zst bsdgames-darwin-36303db1c8b4eb1d4def70b89273c5937763a9f3.zip |
avoid uninit memory and use memmove vs strncpy for a will be
truncated on purpose string.
-rw-r--r-- | tetris/scores.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tetris/scores.c b/tetris/scores.c index 04424cb4..1335df7b 100644 --- a/tetris/scores.c +++ b/tetris/scores.c @@ -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 @@ putscores(int sd) { #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 @@ putscores(int sd) 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; |