Menu ▾ ▴

#143 IRegistryGuard.TryReadStringList trusts 'Count' without a limit

unread
nobody
2 days ago
2 days ago
No

TryReadStringList in u_dzClassUtils reads a list in the format WriteStringList writes: the REG_DWORD 'Count' and the items Item0 to Item<count -="" 1="">. It loops to 'Count' - 1 without any limit, and adds '' for every missing item. A corrupt or foreign 'Count' such as $7FFFFFFF means about two billion registry queries and Add('') calls: the program hangs and finally runs out of memory, although the function is meant to return False for data it cannot use.</count>

A limit needs a decision: the number of values in the key (TRegistry.GetKeyInfo) is not enough on its own, as missing items are allowed and come back as ''. One possibility: return False if 'Count' is negative or larger than the number of values in the key, as a list WriteStringList wrote has all its items.

Found in the review of the fix for [bugs:#137] (r2601), by reading the code, not observed.

Related

Bug Reports: #137

Discussion


Log in to post a comment.