Nmap Security Scanner
*Intro
*Ref Guide
*Install Guide
*Download
*Changelog
*Book
*Docs
Security Lists
*Nmap Hackers
*Nmap Dev
*Bugtraq
*Full Disclosure
*Pen Test
*Basics
*More
Security Tools
*Pass crackers
*Sniffers
*Vuln Scanners
*Web scanners
*Wireless
*Exploitation
*Packet crafters
*More
Site News
Site Search:
Exploit World
Advertising
About/Contact
Credits
Sponsors:
edgeos



Vulnerability Development: Re: Secure coding in C (was Re: Administrivia #4883)

Re: Secure coding in C (was Re: Administrivia #4883)

From: Bennett Todd <bet_at_RAHUL.NET>
Date: Fri, 14 Jan 2000 16:58:33 -0500

2000-01-14-16:48:50 Marco Walther:
> BT> snprintf(c, len, "%s%s", a, b) > 0 || die "snprintf";
>
> You're dead! Use (*a == '\0' && *b == '\0') and snprintf() returns `0'!!

Thanks for the tip. I knew about, and ignored that possibility; in
this case the values I'm concatenating come from various sources,
some of which are guaranteed to be non-null, and the format string
actually includes some literal characters, not just a bunch of %s's.

I'm building up a maildir file name, actually. And I _know_ that
someone, someday, is going to use my program to pick a field out of
the header and directly use that as a folder name, so I better be
able to soak up hostile strings showing up:-).

And for whatever it's worth, I consider ``die("snprintf")'' to be a
healthy response to an otherwise-unchecked hostile string, at least
in this setting:-).

-Bennett

<HR NOSHADE>
<UL>
<LI>application/pgp-signature attachment: stored
</UL>
Received on Jan 14 2000

[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]
edgeos