Skip to content

Remove last occurrence of potentially insecure function sprintf - #1777

Merged
jgarzik merged 1 commit into
bitcoin:masterfrom
laanwj:2012_09_eliminate_sprintf
Sep 4, 2012
Merged

jgarzik merged 1 commit into
bitcoin:masterfrom
laanwj:2012_09_eliminate_sprintf

Conversation

@laanwj

@laanwj laanwj commented Sep 3, 2012

Copy link
Copy Markdown
Member

%d can return up to 11 characters (12 with \0). Move away from fixed buffer completely and use our own safe function strprintf.

I'm reasonably sure that this cannot be exploited due to earlier checks, but it does make me feel a tad uneasy.

Comment thread src/net.cpp Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems you have a "." too much here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Good catch.

%d can return up to 11 characters. Move away from fixed buffer completely and
use our own safe function strprintf.
@Diapolo

Diapolo commented Sep 3, 2012

Copy link
Copy Markdown

@laanwj

laanwj commented Sep 3, 2012

Copy link
Copy Markdown
Member Author

I thought I removed that sprintf months ago. At least I rewrote a similar function in util.cpp. That function should use the existing HexStr function.

Edit: I see the reason now. uint256.h cannot include util.h, as util.h includes uint256.h, So uint256 cannot simply use HexStr unless we move that to a third .h file...

jgarzik pushed a commit that referenced this pull request Sep 4, 2012
Remove last occurrence of potentially insecure function sprintf
@jgarzik
jgarzik merged commit 2fd6f06 into bitcoin:master Sep 4, 2012
@laanwj
laanwj deleted the 2012_09_eliminate_sprintf branch April 9, 2014 14:18
owlhooter pushed a commit to owlhooter/mazacoin-new that referenced this pull request Oct 10, 2018
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants