diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2011-06-20 17:40:56 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2011-06-20 17:40:56 +0000 |
commit | 78105b9fbcc02388d69bc6832c04f9ee427fa863 (patch) | |
tree | f5b07e8499baca5d2034853eca925fcaa0aadf92 /games/sail/sync.c | |
parent | cc261b1574c30dd0d7cb42f3e94172e950f444cb (diff) |
Do not compare a `char' variable to EOF, which does not fit if `char' defaults
to unsigned (e.g. arm, powerpc); ok guenther@ matthew@ looks good deraadt@
Diffstat (limited to 'games/sail/sync.c')
-rw-r--r-- | games/sail/sync.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/games/sail/sync.c b/games/sail/sync.c index 9bf85efac9e..73b8d69eef5 100644 --- a/games/sail/sync.c +++ b/games/sail/sync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sync.c,v 1.9 2009/10/27 23:59:27 deraadt Exp $ */ +/* $OpenBSD: sync.c,v 1.10 2011/06/20 17:40:55 miod Exp $ */ /* $NetBSD: sync.c,v 1.9 1998/08/30 09:19:40 veego Exp $ */ /* @@ -253,16 +253,18 @@ Sync() if (isstr != 0 && isstr != 1) goto bad; if (isstr) { + int ch; char *p; + for (p = buf;;) { - switch (*p++ = getc(sync_fp)) { + ch = getc(sync_fp); + switch (ch) { case '\n': - p--; case EOF: break; default: - if (p >= buf + sizeof buf) - p--; + if (p < buf + sizeof buf) + *p++ = ch; continue; } break; |