Argc/Argv Programming
#include <stdio.h>
int main (int argc, char *argv[]){
int count;
printf ("This program was called with \"%s\".\n",argv[0]);
if (argc > 1) {
for (count = 1; count < argc; count++){
printf("argv[%d] = %s\n", count, argv[count]);
}
}
else {
printf("The command had no other arguments.\n");
}
return 0;
}
sscanf의 활용
/* sscanf example */
#include <stdio.h>
int main ()
{
char sentence []=“John is 12 years old";
char str [10];
int i;
sscanf (sentence,"%s is %d",str, &i);
printf ("%s -> %d\n",str,i); //출력 결과: John -> 12
return 0;
}
/* sscanf example 2*/
#include <stdio.h>
int main ()
{
char sentence []=“John_Hyung_Kim is 1238179278479183749173 years old";
char str [10];
int i;
sscanf (sentence,"%s is %d",str, &i); //integer overflow 발생 지점
printf ("%s -> %d\n",str,i); //출력 결과: John_Hyung_Kim -> -1
return 0;
}
'Study > Software Security' 카테고리의 다른 글
[소프트웨어보안] 컴퓨터의 구조 및 소프트웨어 실행 원리, C언어와 어셈블리어의 이해 (0) | 2022.10.19 |
---|---|
[소프트웨어보안] 소프트웨어의 정적 분석 방법 (0) | 2022.10.12 |
[소프트웨어보안] Security advisories, CVE (0) | 2022.10.12 |
[소프트웨어보안] 소프트웨어의 개발 절차 및 보안관리, 취약점에 대한 Public Advisory (0) | 2022.10.05 |
[소프트웨어보안] SW 보안의 5 요소 (0) | 2022.09.28 |