Saturday, December 04, 2021

Re: Add support for %0d format specifier to base m4

- long width;
+ int width;

and then:

- width = strtol(argv[pos++], NULL, 10);
+ width = (int)strtol(argv[pos++], NULL, 10);

This is not right.

You need to leave the type as long, and then range check it. I understand
you are uncomfortable passing it later in an int context, where it gets
truncated. But truncating it explicitly like that a cast is even worse.
A huge number should not get bits chopped off and behave strangely, it
should behave like the standard printf operation.

No comments:

Post a Comment