summaryrefslogtreecommitdiffstats
path: root/hunt/huntd
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2014-03-30 05:30:28 +0000
committerdholland <dholland@NetBSD.org>2014-03-30 05:30:28 +0000
commit4ddaf6127ab2fdcf268b76c9a33cb08bc276bfbf (patch)
treec5e563bc63ca82d2116ea9fce3f896dae11ad51f /hunt/huntd
parentf0f60ae760a0274a50d65666e97a141a29287a8f (diff)
downloadbsdgames-darwin-4ddaf6127ab2fdcf268b76c9a33cb08bc276bfbf.tar.gz
bsdgames-darwin-4ddaf6127ab2fdcf268b76c9a33cb08bc276bfbf.tar.zst
bsdgames-darwin-4ddaf6127ab2fdcf268b76c9a33cb08bc276bfbf.zip
Remove SHORTLEN and LONGLEN defines; use sizeof() properly instead.
Fix two semi-compensating size bugs in wire transmission affecting 64-bit machines.
Diffstat (limited to 'hunt/huntd')
-rw-r--r--hunt/huntd/answer.c34
-rw-r--r--hunt/huntd/hunt.h4
2 files changed, 19 insertions, 19 deletions
diff --git a/hunt/huntd/answer.c b/hunt/huntd/answer.c
index 5f42abe4..183521b5 100644
--- a/hunt/huntd/answer.c
+++ b/hunt/huntd/answer.c
@@ -1,4 +1,4 @@
-/* $NetBSD: answer.c,v 1.21 2014/03/30 01:44:37 dholland Exp $ */
+/* $NetBSD: answer.c,v 1.22 2014/03/30 05:30:28 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: answer.c,v 1.21 2014/03/30 01:44:37 dholland Exp $");
+__RCSID("$NetBSD: answer.c,v 1.22 2014/03/30 05:30:28 dholland Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -48,9 +48,9 @@ __RCSID("$NetBSD: answer.c,v 1.21 2014/03/30 01:44:37 dholland Exp $");
#define SCOREDECAY 15
-static char Ttyname[NAMELEN];
+static char Ttyname[WIRE_NAMELEN];
-static IDENT *get_ident(uint32_t, uint32_t, char *, char);
+static IDENT *get_ident(uint32_t, uint32_t, const char *, char);
static void stmonitor(PLAYER *);
static void stplayer(PLAYER *, int);
@@ -59,10 +59,10 @@ answer(void)
{
PLAYER *pp;
int newsock;
- static u_long mode;
- static char name[NAMELEN];
+ static uint32_t mode;
+ static char name[WIRE_NAMELEN];
static char team;
- static int enter_status;
+ static int32_t enter_status;
static socklen_t socklen;
static uint32_t machine;
static uint32_t uid;
@@ -109,15 +109,15 @@ answer(void)
}
version = htonl((uint32_t) HUNT_VERSION);
- (void) write(newsock, &version, LONGLEN);
- (void) read(newsock, &uid, LONGLEN);
+ (void) write(newsock, &version, sizeof(version));
+ (void) read(newsock, &uid, sizeof(uid));
uid = ntohl(uid);
- (void) read(newsock, name, NAMELEN);
+ (void) read(newsock, name, sizeof(name));
(void) read(newsock, &team, 1);
- (void) read(newsock, &enter_status, LONGLEN);
- enter_status = ntohl((unsigned long) enter_status);
- (void) read(newsock, Ttyname, NAMELEN);
- (void) read(newsock, &mode, sizeof mode);
+ (void) read(newsock, &enter_status, sizeof(enter_status));
+ enter_status = ntohl(enter_status);
+ (void) read(newsock, Ttyname, sizeof(Ttyname));
+ (void) read(newsock, &mode, sizeof(mode));
mode = ntohl(mode);
/*
@@ -398,7 +398,7 @@ rand_dir(void)
* Get the score structure of a player
*/
static IDENT *
-get_ident(uint32_t machine, uint32_t uid, char *name, char team)
+get_ident(uint32_t machine, uint32_t uid, const char *name, char team)
{
IDENT *ip;
static IDENT punt;
@@ -407,7 +407,7 @@ get_ident(uint32_t machine, uint32_t uid, char *name, char team)
if (ip->i_machine == machine
&& ip->i_uid == uid
&& ip->i_team == team
- && strncmp(ip->i_name, name, NAMELEN) == 0)
+ && strncmp(ip->i_name, name, WIRE_NAMELEN) == 0)
break;
if (ip != NULL) {
@@ -427,7 +427,7 @@ get_ident(uint32_t machine, uint32_t uid, char *name, char team)
ip->i_machine = machine;
ip->i_team = team;
ip->i_uid = uid;
- strncpy(ip->i_name, name, NAMELEN);
+ strncpy(ip->i_name, name, sizeof(ip->i_name));
ip->i_kills = 0;
ip->i_entries = 1;
ip->i_score = 0;
diff --git a/hunt/huntd/hunt.h b/hunt/huntd/hunt.h
index daff100b..82605662 100644
--- a/hunt/huntd/hunt.h
+++ b/hunt/huntd/hunt.h
@@ -1,4 +1,4 @@
-/* $NetBSD: hunt.h,v 1.29 2014/03/30 01:44:37 dholland Exp $ */
+/* $NetBSD: hunt.h,v 1.30 2014/03/30 05:30:28 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
@@ -56,7 +56,7 @@ typedef struct ident_def IDENT;
typedef struct regen_def REGEN;
struct ident_def {
- char i_name[NAMELEN];
+ char i_name[WIRE_NAMELEN];
char i_team;
uint32_t i_machine;
uint32_t i_uid;