Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Nov 1998 23:25:51 -0700 (MST)
From:      "Justin T. Gibbs" <gibbs@narnia.plutotech.com>
To:        Matthew Dillon <dillon@apollo.backplane.com>
Cc:        current@FreeBSD.ORG
Subject:   Re: snprintf() in the kernel
Message-ID:  <199811210625.XAA05877@narnia.plutotech.com>
In-Reply-To: <199811210312.TAA25314@bubba.whistle.com> <199811210407.UAA20321@apollo.backplane.com> <199811210537.VAA20822@apollo.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <199811210537.VAA20822@apollo.backplane.com> you wrote:
>     General comments:

...

> 	* noticed a few bugs in the original code were fixed, kudos!  For
> 	  example, a number of strncpy()'s assume zero-termination.  strncpy()
> 	  does not zero-terminate in the exact-length case.

Exactly.  Many of the uses of strncpy removed from the CAM code
fall into this category.

> cam/scsi/scsi_all.c
> 
>     line 1566, char holdstr[8] was totally broken anyway, it wasn't big
>     enough (needs to be 10).  Your patch removes it which is good.  
>     A second bug fixed!

Last I checked, an unsigned  byte value represented in hex took 2 bytes.
The space and the null terminator add 2 more bytes.  That makes holdstr
too big by 4 bytes.

> dev/buslogin/bt.c
> 
>     Boy, weren't we lucky that all BT model names were 4 characters!

Of course they are always 4 characters long.  How do you think the programmer
determined the correct amount of space to allocate for the name information
in the first place?

--
Justin

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811210625.XAA05877>