@@ -75,4 +75,41 @@ void ODBCTests(){
7575 gets (userInput );
7676 SQLPrepare (0 , userInput , 100 ); // BAD
7777 SQLExecDirect (0 , userInput , 100 ); // BAD
78+ }
79+
80+ // Oracle Call Interface (OCI) Routines
81+ int OCIStmtPrepare (
82+ void * arg0 ,
83+ void * arg1 ,
84+ const unsigned char * sql ,
85+ unsigned int arg3 ,
86+ unsigned int arg4 ,
87+ unsigned int arg5 );
88+ int OCIStmtPrepare2 (
89+ void * arg0 ,
90+ void * * arg1 ,
91+ void * arg2 ,
92+ const unsigned char * sql ,
93+ unsigned int arg4 ,
94+ const unsigned char * arg5 ,
95+ unsigned int arg6 ,
96+ unsigned int arg7 ,
97+ unsigned int arg8 );
98+
99+ void OCITests (){
100+ char userInput [100 ];
101+ gets (userInput );
102+
103+ // a string from the user is injected directly into an SQL query.
104+ char query1 [1000 ] = {0 };
105+ snprintf (query1 , 1000 , "SELECT UID FROM USERS where name = \"%s\"" , userInput );
106+ OCIStmtPrepare (0 , 0 , query1 , 0 , 0 , 0 ); // BAD
107+ OCIStmtPrepare2 (0 , 0 , 0 , query1 , 0 , 0 , 0 , 0 , 0 ); // BAD
108+
109+ // an integer from the user is injected into an SQL query.
110+ int userNumber = atoi (userInput );
111+ char query2 [1000 ] = {0 };
112+ snprintf (query2 , 1000 , "SELECT UID FROM USERS where number = \"%i\"" , userNumber );
113+ OCIStmtPrepare (0 , 0 , query2 , 0 , 0 , 0 ); // GOOD
114+ OCIStmtPrepare2 (0 , 0 , 0 , query2 , 0 , 0 , 0 , 0 , 0 ); // GOOD
78115}
0 commit comments