cvs commit: src/sys/kern subr_bus.c subr_rman.c vfs_subr.c src/sys/net if_mib.c src/sys/netinet ip_divert.c raw_ip.c udp_usrreq.c

John-Mark Gurney gurney_j at resnet.uoregon.edu
Thu May 5 23:54:21 PDT 2005


Warner Losh wrote this message on Fri, May 06, 2005 at 00:24 -0600:
> Yes, I understand that.  But Like I said before, it is better to zero
> the entire hunk of memory with bzero or M_ZERO....
> 
> The problem with strncpy is that it doesn't guarantee NUL
> termination when strlen(s) > sizeof(d).

And depending upon the interface, this is a good thing... I know that
there are a few interfaces out there that use all chars for the array
and assume that the userland program knows that when the array is full,
to self terminate...  Luckily, with such things as printf, you can still
safely print such a string...  (Hint to the other readers: It involves
a `.' and a `*'.)

But now we are getting down into semantics...  I was just pointing out
that if the buffer was filled with strncpy, we don't have to worry about
leaking information...  I didn't completely understand this till just
over a year ago, and I'm probably not the only one that forgets/doesn't
remeber/never knew that strncpy behaved this way...

I didn't see any cases of this in the patches that were submitted, but
I also only checked one file...

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."


More information about the cvs-src mailing list