Closed Bug 246605 Opened 21 years ago Closed 16 years ago

String registry entries should be null-terminated

Categories

(Core Graveyard :: File Handling, defect)

x86
Windows NT
defect
Not set
major

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: neil, Unassigned)

References

()

Details

(Keywords: helpwanted)

Quoted from the MSDN entry for RegSetValueEx: cbData [in] Size of the information pointed to by the lpData parameter, in bytes. If the data is of type REG_SZ, REG_EXPAND_SZ, or REG_MULTI_SZ, cbData must include the size of the terminating null character or characters. However we do not actually include the terminating null character in cbData. This could potentially crash a third-party application.
This is actually an entirely false problem, so long as the string we point Windows to /does/ have a null on the end. I've checked with a test app, and if you pass it (for example) a buffer with 10 characters followed by a null, but a length of only 10, it actually saves an 11 character string into the registry. Also, even if you have just the 10 character buffer (with no null) and pass it a length of 10, while it only saves 10 characters to the registry, the buffer when reading it *is* null-terminated for you (but only if you have that extra character of space, of course). Needs fixing, but Windows is already coping with our bugs. ;)
We shouldn't ignore docs just because some versions of Windows are forgiving...
Assignee: file-handling → nobody
QA Contact: ian → file-handling
Winhooks code is dead => WONTFIX
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → WONTFIX
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.