WPI Social Implications Of Computing
Course Documents
Assignments
Past
                                          
Printer Friendly Version
Buffer Overrun

Intro ] [ BufferOverrun.c ] [ BufferOverrun.exe ] [ Display BufferOverrun Code ]

Up: 2015 A Term Course Documents ]

#include <stdio.h>
#include <string.h>

int main ( void )
{
  char buff [ 15 ];
  int ace = 0;

  printf ( "\n Enter best class ever : \n" );
  gets ( buff ); // the naughty line

  if ( strcmp ( buff, "imps" ) )
    {
      printf ( "\n %s is wrong! You should FAIL! \n ace=%i\n", 
	       buff, ace );
    }
  else
    {
      printf ( "Correct! \n") ;
      ace = 1;
    }

  if ( ace )
    {
      printf ( "You get an A! \n" );
    }

  return 0;
}

by: Keith A. Pray
Last Modified: March 5, 2017 9:17 PM
© 2017 - 1975 Keith A. Pray.
All rights reserved.

Current Theme: 

Kapowee Hosted | Kapow Generated in 0.007 second | XHTML | CSS