diff options
author | Chris Kuethe <ckuethe@cvs.openbsd.org> | 2006-06-01 23:17:09 +0000 |
---|---|---|
committer | Chris Kuethe <ckuethe@cvs.openbsd.org> | 2006-06-01 23:17:09 +0000 |
commit | 73872092b222a695c4736d7bc44beec73b0bf74d (patch) | |
tree | 476ac5896299a24ae73081739d4f44f4e43cb31f /sys | |
parent | cd885f1198963ef94705e2a9907db540238e32de (diff) |
Avoid buffer overflow in case of oversized input.
ok mbalmber
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/tty_nmea.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/kern/tty_nmea.c b/sys/kern/tty_nmea.c index bde37380fc2..5a1fa9b547a 100644 --- a/sys/kern/tty_nmea.c +++ b/sys/kern/tty_nmea.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_nmea.c,v 1.2 2006/06/01 22:32:46 ckuethe Exp $ */ +/* $OpenBSD: tty_nmea.c,v 1.3 2006/06/01 23:17:08 ckuethe Exp $ */ /* * Copyright (c) 2006 Marc Balmer <mbalmer@openbsd.org> @@ -267,8 +267,10 @@ nmea_hdlr(struct nmea *np, int c) void nmea_bufadd(struct nmea *np, int c) { - np->cbuf[np->pos++] = c; - np->cksum ^= c; + if (np->pos < NMEAMAX){ + np->cbuf[np->pos++] = c; + np->cksum ^= c; + } } /* |