I'm developing an application that allows user to input hostnames, database names, usernames, and passwords for database access. The application will construct a ODBC connect string by filling in the placeholders. In C, that would translate to something like:
snprintf(connStr, sizeof(connStr),
"DRIVER={%s};SERVER={%s};DATABASE={%s};UID={%s};PWD={%s}",
myDriver, hostName, dbName, userName, passWord);
First thing I thought -- I need to excise the ";" character from everything. (And instruct users their passwords can't contain semicolons.)
Am I vulnerable to some kind of hostile input in this case? (Before you ask, yes, I will check for excessively large input. You can assume the connStr buffer will be enough. Either that or I'll use a higher level language with managed string types.)