On Mon, Apr 17, 2006 at 07:06:51PM +0000, Rui Paulo wrote:
|
| Module Name: src
| Committed By: rpaulo
| Date: Mon Apr 17 19:06:51 UTC 2006
|
| Modified Files:
| src/sys/dev/pci: if_ipw.c if_ipwvar.h
|
| Log Message:
| Oops, 16 is not enough to store the firmware filenames, use 24.
|
|
| To generate a diff of this commit:
| cvs rdiff -r1.17 -r1.18 src/sys/dev/pci/if_ipw.c
| cvs rdiff -r1.9 -r1.10 src/sys/dev/pci/if_ipwvar.h
I believe that it's far better style (and less error prone) to use:
char foo[24];
strncpy(foo, bar, sizeof(foo));
than
char foo[24];
strncpy(foo, bar, 24);
I.e, use sizeof() appropriately.
For that matter, I think in this situation it's even
better to use strlcpy():
strlcpy(foo, bar, sizeof(foo));
since strncpy() does not NUL terminate if the length
of the src (excluding NUL) is the provided size, and
you're calling firmware_open() which expects the filename
to be NUL terminated.
IMHO, strncpy() should only be used when copying to a destination
where the API for that destination doesn't need a NUL termination,
such as the disklabel(5) type & pack fields, or utmp(5) fields.
cheers,
Luke.
Attachment:
pgpd6pWx4eXlo.pgp
Description: PGP signature