Январь 2009

Загадочные точки с запятой

21.01.2009

Источник: http://www.dtf.ru/forum/thread.php?id=193131&set_mode=1

Цитирую: “Я видел где-то код, в котором после отступов ставят точки с запятой. Вот приблизительно таким образом. Вы подобное встречали? Зачем ставят пустые команды после отступов?”

void func (void)
{
int a, b[2], i;

for (a=0;a<3;a++) {
; ; if (b[i]==4) {
; ; ; b [i] = 14;
; ; }
}

}

Защита от SQL injection

03.01.2009

Источник: http://thedailywtf.com/Articles/SQL-Injection-Protection–3.aspx

// The following string is an SQL comment, and could
// blank out the check for password in our SQL statement
// if used in the username!
if (username.indexOf(”‘;–”)!=-1) {
throw new AuthorisationException(username +” given as login name contains ‘;–, this is bad for SQL!”);
}

// Get the (hopefully single) id of the player with
// this name and password
ResultSet authorised = statement.executeQuery( “SELECT id FROM table_name_redacted WHERE ” + “username=’”+username +”‘ AND password=’”+password+”‘;”)