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

Use snprintf #6

Open
su8 opened this issue Feb 14, 2021 · 4 comments
Open

Use snprintf #6

su8 opened this issue Feb 14, 2021 · 4 comments

Comments

@su8
Copy link

su8 commented Feb 14, 2021

sprintf(src, "v%x_%x", type, var);
can overflow u should use snprintf

@kollokollo
Copy link
Contributor

Can you be more specific? What can overflow?

@su8
Copy link
Author

su8 commented Feb 17, 2021

static unsigned char vbuf[11]; /* vffff_ffff\0 */
hold élévén chars and if both héx numbérs excééd thosé élévén chars we havé ovérflow and stacksmash

@kollokollo
Copy link
Contributor

Hm, Ok, so far so good, but each of the hex values can have only 4 charackters, so together this is 1+4+1+4+1=11. This should fit.

@kollokollo
Copy link
Contributor

However, you are right: The new gcc version produces a lot of warnings about probably bad coding style... This could eventully be fixed. However the code works anyways, and since it is rather old, this would probably not be wirth the effort. But If you like, you could make a patch.

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

2 participants