/* BufferOverflow.c
 * Author: Dean F. Hougen
 * Copyright: 2002-2003, all rights reserved.
 *
 * This program shows buffer overflows caused by gets().  In this program,
 * a buffer overflow can be used to compromise the safety of other data in
 * the program.
 */

#include <stdio.h>
#include <errno.h>

int main (void){
    fcn();
}

int fcn (void){
    char username[9];
    char password[9];
    char realname[20];

    printf("Please enter your username: ");
    if (NULL == gets(username)){
        perror("Error with gets:");
        exit(1);
    }

    printf("Please enter your full (real) name: ");
    if (NULL == gets(realname)){
        perror("Error with gets:");
        exit(1);
    }

    printf("Please enter your password: ");
    if (NULL == gets(password)){
        perror("Error with gets:");
        exit(1);
    }

    printf("Thank you %s\n", realname);

    exit(0);
}