fixed potential buffer overrun by adding "10" to port parameter in sscanf
return error if port is invalid (>65535)
added tests
Details
- Reviewers
sivachandra ovyalov clayborg
Diff Detail
Event Timeline
/Users/vharron/ll/svn/lldb/source/Utility/UriParser.cpp | ||
---|---|---|
42 ↗ | (On Diff #17987) | You may define port_tmp as auto instead of integer - otherwise if result of strtoul is greater than MAX_INT but less than max of unsigned long int it might be just a negative number. |
43 ↗ | (On Diff #17987) | Check for portr_tmp <= 0? |
I would prefer this to use Args::StringToUInt32() instead of a manual call to strtoul() from #include "lldb/Interpreter/Args.h" (even though the correct usage of strtoul() is used here). This helps abstract us from the host we are running on in case there is no strtoul() and also leads me to the fact that the Args::StringTo* calls could actually be moved into the host layer.
You might also be better off using the RegularExpression class to parse these instead of sscanf, but this isn't a required change.
Changed port output parameter to be -1 if port is unspecified
This makes more sense because we might want to be able to
differentiate between port unspecified and port==0