0
 `  
    int main(){
    char a[10];
    char he[10]="hello";
    char c[10]="password";
    printf("please enter a string:\n");
    scanf("%s",a);
    printf("your string is :%s\n",a);
    printf("your string is :%s\n",he);
    printf("your string is :%s\n",c); 
    }
 `

I watched some videos about vulnerabilities on scanf and gets functions ,and as I saw when someone entered a number of characters that highest than the size of the array a ,the remains
characters overwrites the next array ,but that's not the case in my program so i want the know why?

  • Perhaps the variables appear on the stack in the opposite order on your computer so maybe you need to scanf into c? Or maybe there is padding around the array so your compiler can check if you overwrite the array. You can do it but it depends on your machine, OS and compiler and all of them will deal with undefined behavior differently. It does work on https://onlinegdb.com/f4skIKIFD – Jerry Jeremiah Feb 22 '23 at 03:18

0 Answers0