Address infinite loop when processing $GENERATE

In nibble mode if the value to be converted was negative the parser
would loop forever.  Process the value as an unsigned int instead
of as an int to prevent sign extension when shifting.

This was found by Eric Sesterhenn from X41.

(cherry picked from commit 371824f078)
This commit is contained in:
Mark Andrews 2024-01-19 12:37:10 +11:00
parent 1bc1fc5a18
commit 58efb2f740

View file

@ -626,7 +626,8 @@ static const char *hex = "0123456789abcdef0123456789ABCDEF";
* counting the terminating NUL.
*/
static unsigned int
nibbles(char *numbuf, size_t length, unsigned int width, char mode, int value) {
nibbles(char *numbuf, size_t length, unsigned int width, char mode,
unsigned int value) {
unsigned int count = 0;
/*