[OpenBIOS] Sparc32 "see" crashes on "" literals
Tarl Neustaedter
Tarl.Neustaedter at Sun.COM
Sat Jan 24 21:07:38 CET 2009
Stefan Reinauer wrote:
> [...]
> See patch.. There seems to be another oddity in " which caused me to use
> s" instead of " in nvram.fs... Who finds the remaining problem? ;-)
>
What's the distinction between s" and " ?
One of the persistent problems we run into at Sun (in particular
relating to NVRAM and properties being passed to Solaris) is the
dichotomy between counted strings and null-terminated strings. A string
constant ( " ) is a counted string, but supposedly with a terminating
null outside the count, which ensures that any C-code doesn't barf on
being passed a pointer to the string. The problem often arises when
string constants are copied, which doesn't necessarily bring along the
null terminator - passing such a copied string can cause problems in
careless C code.
An example I recall was code in Solaris' consconfig.c which would
complain when it didn't like the values it found in ttya-mode. It would
print out an error message using sprintf's %s to reference the property,
and that could run off the end of the universe. Another example was in
comparisons for property values, where sometimes a string value for a
property /included/ a terminating null byte (depending on how the
property was created) and sometimes didn't - which could cause problems
in not being able to match values.
More information about the OpenBIOS
mailing list