From owner-freebsd-audit Fri Aug 4 14:10: 6 2000 Delivered-To: freebsd-audit@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 758) id D10DE37B69F; Fri, 4 Aug 2000 14:10:03 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id CEBEC2E8194; Fri, 4 Aug 2000 14:10:03 -0700 (PDT) (envelope-from kris@hub.freebsd.org) Date: Fri, 4 Aug 2000 14:10:03 -0700 (PDT) From: Kris Kennaway To: Warner Losh Cc: audit@FreeBSD.ORG Subject: Re: ether_line() patch In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Fri, 4 Aug 2000, Kris Kennaway wrote: > strncpy does not null-terminate if strlen(result) == resultlen. In that > case the buf[resultlen] character will be stomped by the NULL - it's a > trivial change, but I think it's correct. Actually we were both wrong - this strncpy was just bogus and did no bounds checking. This patch hunk should be better. @@ -156,8 +178,8 @@ strlen(ether_a), &result, &resultlen)) { continue; } - strncpy(buf, result, resultlen); - buf[resultlen] = '\0'; + strncpy(buf, result, sizeof(buf) - 1); + buf[sizeof(buf)] = '\0'; free(result); } #endif Kris -- In God we Trust -- all others must submit an X.509 certificate. -- Charles Forsythe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message