Created
August 1, 2019 15:40
-
-
Save parzibyte/77303c6c5a8414d427121424336a175d to your computer and use it in GitHub Desktop.
Ejemplo de desbordamiento de búfer en C - https://parzibyte.me/blog/2018/11/18/desbordamiento-de-bufer-en-c/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Ejemplo simple de desbordamiento de búfer en C | |
@author parzibyte | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
int main() { | |
char cadena[3]; | |
int autenticado = 0; // 1 es que sí, 0 que no | |
printf("Ingresa la contraseña:\n"); | |
scanf("%s", cadena); | |
if (strcmp(cadena, "123") == 0) { | |
autenticado = 1; | |
} | |
if (autenticado) | |
printf("Bienvenido al programa"); | |
else | |
printf("Acceso denegado"); | |
printf("\nAl final de todo, el valor que tiene 'autenticado' es: %d", | |
autenticado); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment