Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Defensive Programming Squad

Name: Anonymous 2008-10-22 5:59

In this thread we pick up innocent programs and tank the shit out of them.

#include <stdio.h>
int main () {
  int n1, n2;
  printf("First integer:");
  scanf("%d", &n1);
  printf("Second integer:");
  scanf("%d", &n2);
  printf("Sum = %d\n", n1+n2);
  return 0;
}

Name: Anonymous 2008-10-23 9:44

>>23
It's a little more complicated than that...
/* Anonix ed - Version 1.0 */

#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  char line[LINE_MAX];
  signal(SIGINT, &int_handler);
  signal(SIGHUP, &hup_handler);
  signal(SIGQUIT, SIG_IGN);
  while(fgets(line, LINE_MAX, stdin) && strcmp(line, "q\n")) puts("?");
  return 0;
}

void int_handler(int){
  puts("?");
  fpurge(stdin);
}

void hup_handler(int){
  FILE * f;
  if(f = open("ed.hup", "w+")) fclose(f);
  if(getenv("HOME")){
   char path[strlen(getenv("HOME)) + 8];
   strcpy(path, getenv("HOME"));
   strcat(path, "/ed.hup");
   if(f = open(path, "w+")) fclose(f);
  }
  _Exit(0);
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List