[Owasp-esapi-c++] containsCharacter( char, char[])

Daniel Amodio dan.amodio at aspectsecurity.com
Fri Aug 5 10:11:27 EDT 2011


Then really we should force passing it in a container that specifies length. 
Otherwise... who's to say they don't pass a bad length (intentionally or unintentionally)?

-----Original Message-----
From: Kevin W. Wall [mailto:kevin.w.wall at gmail.com] 
Sent: Friday, August 05, 2011 10:07 AM
To: Daniel Amodio
Cc: noloader at gmail.com; ESAPI C++ List
Subject: Re: [Owasp-esapi-c++] containsCharacter( char, char[])

On Fri, Aug 5, 2011 at 9:48 AM, Daniel Amodio <dan.amodio at aspectsecurity.com> wrote:
> Would there be any drawback to providing functions for a couple different types? Or should we force developers to use the safer methods?
>
> I'm thinking some developers may rely heavily on char, char[]s or std::string, and may be frustrated at converting them.
> We can had some methods that convert and then call the "safe" method.
>
> containsChar(char, char[]) {
> // convert
> return containsChar(safeType, otherSafeType); }
>
> You can get the length of char arrays by doing 
> sizeof(theArray)/sizeof(char), so that may prevent overruns

You are forgetting C++'s ugly warts it inherits from C.  Note that 'char*' and 'char[]' can be used interchangebly. And whose to say that 'char*' is really meant to point to a null-terminated C string?

No, I think we need to make passing the length explicit for char[].

-kevin
--
Blog: http://off-the-wall-security.blogspot.com/
"The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals.
We *cause* accidents."        -- Nathaniel Borenstein


More information about the Owasp-esapi-c++ mailing list