4 ms·
strncmp and other API that treats the pointer to the string and its length as separable variables are not dangerous. They are much more secure than the non 'n'
by Kubuxu 9y ago
strncmp and other API that treats the pointer to the string and its length as separable variables are not dangerous. They are much more secure than the non 'n' options.
With them you don't have to worry about lack of null termination as the n determines the length of the string.
Problem here was usage of them at all. Hashes are not really strings, memcmp should have been used or even better secure (that doesn't leek timings) memcmp should be used.
Problem here was just mistake in the program not in the C lib.
- geofft 9y ago> strncmp and other API that treats the pointer to the string and its length as separable variables are not dangerous. They are much more secure than the non 'n' options. "More secure" doesn't imply "not dangerous". It's definitely safer to drive a car without seatbelts than to ride a bike down the highway, but that doesn't mean that not wearing your seatbelt isn't dangerous. > Problem here was usage of them at all. Hashes are not really strings, memcmp should have been used or even better secure (that doesn't leek timings) memcmp should be used. This is incorrect for two reasons. The first is that hashes in ASCII format are strings: it's useful to want, for example, case-insensitive hash comparisons. The second is that (if I'm understanding the vulnerability correctly) the exact same bug would be present with memcmp: if (memcmp(target, user_string, user_string_length) == 0) > Problem here was just mistake in the program not in the C lib. Yes. But a library that people make mistakes with all the time is dangerous. If you are a programmer who ever makes mistakes (and clearly the AMT folks are, but I'm pretty sure so is everyone), you should avoid dangerous libraries.