-/* $NetBSD: score.c,v 1.22 2009/08/03 06:04:12 dholland Exp $ */
+/* $NetBSD: score.c,v 1.24 2021/04/13 01:50:46 mrg Exp $ */
/*
* Copyright (c) 1980, 1993
#if 0
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: score.c,v 1.22 2009/08/03 06:04:12 dholland Exp $");
+__RCSID("$NetBSD: score.c,v 1.24 2021/04/13 01:50:46 mrg Exp $");
#endif
#endif /* not lint */
static uint32_t numscores, max_uid;
+static int cmp_sc(const void *, const void *);
+static void set_name(SCORE *);
+
/*
* read_score:
* Read the score file in MI format
lseek(inf, 0, SEEK_SET);
}
-void
+static void
set_name(SCORE *scp)
{
struct passwd *pp;
if ((pp = getpwuid(scp->s_uid)) == NULL)
- strncpy(scp->s_name, "???", MAXNAME);
+ strncpy(scp->s_name, "???", MAXNAME - 1);
else
- strncpy(scp->s_name, pp->pw_name, MAXNAME);
+ strncpy(scp->s_name, pp->pw_name, MAXNAME - 1);
+ scp->s_name[MAXNAME - 1] = '\0';
}
/*
* cmp_sc:
* Compare two scores.
*/
-int
+static int
cmp_sc(const void *s1, const void *s2)
{
return ((const SCORE *)s2)->s_score - ((const SCORE *)s1)->s_score;