From owner-freebsd-audit Fri Aug 4 13:58:18 2000 Delivered-To: freebsd-audit@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 758) id EF6F937BB61; Fri, 4 Aug 2000 13:58:16 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id ECFA82E8196; Fri, 4 Aug 2000 13:58:16 -0700 (PDT) (envelope-from kris@hub.freebsd.org) Date: Fri, 4 Aug 2000 13:58:16 -0700 (PDT) From: Kris Kennaway To: Warner Losh Cc: audit@FreeBSD.ORG Subject: Re: ether_line() patch In-Reply-To: <200008041927.NAA12389@harmony.village.org> 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, Warner Losh wrote: > : - strncpy(buf, result, resultlen); > : + strncpy(buf, result, resultlen - 1); > : buf[resultlen] = '\0'; > : free(result); > : } > : > > This change is wrong. The strcpy puts upto resultlen characters into > buf, and then null terminates it at the resultlen + 1st character > (counting from 1). The strncpy should therefore not have the -1. Or > the line setting the buf[] = 0 should have it as well. 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. 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