Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GCC] warning: ‘%lg’ directive output may be truncated #183

Open
AaronNGray opened this issue Feb 21, 2025 · 0 comments
Open

[GCC] warning: ‘%lg’ directive output may be truncated #183

AaronNGray opened this issue Feb 21, 2025 · 0 comments

Comments

@AaronNGray
Copy link

I think is an issue with GCC's buffer overflow analysis accuracy.

This was reported in GCC v12.4 we are running v13.3.0.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114374

https://github.com/AaronNGray/pdfalto/actions/runs/13463238846/job/37623204502#step:9:450

/home/runner/work/pdfalto/pdfalto/src/AnnotsXrce.cc:444:59: warning: ‘%lg’ directive output may be truncated writing between 1 and 13 bytes into a region of size 8 [-Wformat-truncation=]
450 444 | snprintf(temp, sizeof(temp), "%lg", x);
451 | ^~~
452/home/runner/work/pdfalto/pdfalto/src/AnnotsXrce.cc:444:58: note: assuming directive output of 12 bytes
453 444 | snprintf(temp, sizeof(temp), "%lg", x);
454 | ^~~~~
snprintf(temp, sizeof(temp), "%lg", x);

https://github.com/AaronNGray/pdfalto/blob/buffer-overflows/src/AnnotsXrce.cc#L444

char *temp = (char *) malloc(16 * sizeof(char));

https://github.com/AaronNGray/pdfalto/blob/buffer-overflows/src/AnnotsXrce.cc#L419

It might be an idea to apply -Wformat-truncation just on GCC builds.

@AaronNGray AaronNGray changed the title warning: ‘%lg’ directive output may be truncated [GCC] warning: ‘%lg’ directive output may be truncated Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant