(buffer) . , , , , . , , , , , .
, . , . , , , .
, , . , , .
C Assembler . , , . «» . , , , . - .
, , , . , , .
- , . , . , , . .
. -25 (2009 CWE/SANS Top 25 Most Dangerous Programming Errors) CWE-120 . , .
, . , , , , . , «» «», buffer «», .
, , . «», , , buffer . , user answer , , ask Question.
, , , , . , , , .
, , , , « ». gets buffer. , strcpy, strcmp printf/sprintf, , .
, . . - , . C . , , . Java, Python .NET, , .
, . . , , , . strcpy strcat . , buffer, , .
, . . , , . , , .
, . foo normal buffer, , . . buffer , , .
, C , . - . OpenBSD strlcpy strlcat, strn, , , .
Microsoft : strcpy_s, strcat_s sprintf_s.
, , . , .
C, . , (canary), , . , Windows. , , .
(ASLR). - (DEP) - , , . , .
, ASLR. , .
, . 1980- , . , , UNIX finger , , .
ASLR DEP , , . , , , .
buffer . -, . -, . .
, . , . , , , . , .
buffer. .
. , , - . , .
" " buffer. , . , , .
root
buffer. , , . C/C++, .
, - . . , , . root. , .
root, . , , , , pass. , , pass , root.
. , . , buffer, .
, , , , , .
, , . buffer: . , , , .
- , . , .
/, - .
:
- : 12345678 (8 ), .
- : 123456789 (9 ), « », .
- , argv 8 . 32- (4 ) (32 ). 1 , 5 , 2 (8 ). 8 Buffer .
, , . , strncpy (), strncat () memcpy (). , , .
C/C++ . .
C/C++
C , , , . , , , strcpy. , strncpy. strlen, , NIL. scanf (): scanf (3), fscanf (3), sscanf (3), vscanf (3), vsscanf (3) vfscanf (3) - , , "% s" .
snprintf () C ISO 1990. , sprintf . , Linux snprintf , . snprintf () .
2 Unix (SUS) C99 , snprintf (). snprintf don't , NIL, , NIL. glib g_snprintf () , NIL , , .
buffer. . , , FIFO FIFO , .
, , . .
, . , VISA, , .
VISA Windows 16- FIFO 14 , 2 FIFO, . 4 , , .
, Windows 10, . COM-, , . «», , , UART .
. buffer, . , UART.
. - . - , , , , , .
Veracode , buffer, , . (SAST) Veracode , , .
SAST , , . , , , .
SAST , SQL, (XSS), , . , SAST , .
buffer 3 , - . - -. IT-, .
, , . , .