On (09/27/07 15:17), Artem Kachitchkine wrote: > > >> http://cr.opensolaris.org/~sowmini/arcfixes/ > > mac.c: > > 940 cp = (char *)tmp->b_wptr; > 941 *cp++ = '\0'; > 942 tmp->b_wptr = (uchar_t *)cp; > > Or just: > > *tmp->b_wptr++ = '\0'; > > So, for my education, what's the background on non nul-terminated strings > in so much of networking code (and the need for precautions like strn*)? I > understand when a property value is untyped, i.e. just an array of bytes. > But stuff like names (link names, property names, etc) are strings by > definition, it should be easy to guarantee their nul-terminatedness. Is > this historical?
some of these strings gets passed down on ioctls, so it may not be properly null-terminated, hence the precaution. but in this particular case, the history is even more murky: the ndd code was originally written by mentat, and if you wander into nd_getset, you will find that they have a strange hidden convention of double-null termination (which I was getting wrong). The only known user level program that parses this is /sbin/ndd itself. See, for example http://www.opensolaris.org/jive/thread.jspa?messageID=127515🈛 --Sowmini
