diff options
author | dholland <dholland@NetBSD.org> | 2014-03-30 05:30:28 +0000 |
---|---|---|
committer | dholland <dholland@NetBSD.org> | 2014-03-30 05:30:28 +0000 |
commit | 4ddaf6127ab2fdcf268b76c9a33cb08bc276bfbf (patch) | |
tree | c5e563bc63ca82d2116ea9fce3f896dae11ad51f /hunt/hunt/connect.c | |
parent | f0f60ae760a0274a50d65666e97a141a29287a8f (diff) | |
download | bsdgames-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/hunt/connect.c')
-rw-r--r-- | hunt/hunt/connect.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/hunt/hunt/connect.c b/hunt/hunt/connect.c index 71729c02..4c2e2f7e 100644 --- a/hunt/hunt/connect.c +++ b/hunt/hunt/connect.c @@ -1,4 +1,4 @@ -/* $NetBSD: connect.c,v 1.10 2014/03/30 05:14:47 dholland Exp $ */ +/* $NetBSD: connect.c,v 1.11 2014/03/30 05:30:28 dholland Exp $ */ /* * Copyright (c) 1983-2003, Regents of the University of California. * All rights reserved. @@ -32,31 +32,33 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: connect.c,v 1.10 2014/03/30 05:14:47 dholland Exp $"); +__RCSID("$NetBSD: connect.c,v 1.11 2014/03/30 05:30:28 dholland Exp $"); #endif /* not lint */ #include <string.h> #include <signal.h> #include <unistd.h> +#include <assert.h> #include "hunt_common.h" #include "hunt_private.h" void -do_connect(char *name, char team, long enter_status) +do_connect(const char *name, size_t namelen, char team, int enter_status) { static int32_t uid; - static int32_t mode; + int32_t mode; + int32_t wire_status = htonl(enter_status); if (uid == 0) uid = htonl(getuid()); - (void) write(huntsocket, &uid, LONGLEN); - (void) write(huntsocket, name, NAMELEN); + (void) write(huntsocket, &uid, sizeof(uid)); + assert(namelen == WIRE_NAMELEN); + (void) write(huntsocket, name, namelen); (void) write(huntsocket, &team, 1); - enter_status = htonl(enter_status); - (void) write(huntsocket, &enter_status, LONGLEN); + (void) write(huntsocket, &wire_status, sizeof(wire_status)); (void) strcpy(Buf, ttyname(fileno(stderr))); - (void) write(huntsocket, Buf, NAMELEN); + (void) write(huntsocket, Buf, WIRE_NAMELEN); #ifdef INTERNET if (Send_message != NULL) mode = C_MESSAGE; |