~/ learn/ comp-400/ cards/ Finding and rewriting a vulnerable C program
1 of 7

The vulnerable function, in the form the question always poses it

The vulnerable function, in the form the question always poses it

Answer

int check_tag(void) { char str1[8], str2[8]; int valid = FALSE; next_tag(str1); gets(str2); if (strncmp(str1, str2, 8) == 0) valid = TRUE; return valid; }

Two defects on two lines. `gets(str2)` is unbounded by construction. `next_tag(str1)` is handed a pointer and no size, so it has the same problem — an answer that fixes only the first has fixed half the program.

Stallings & Brown 5e ch10 §10.1–10.2; ch11 §11.2

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/178e52fa-ca05-4224-b1df-2a1386de7743/flashcard utf-8 LF