Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.56 KB | None | 0 0
  1. --- sh.old.c    2010-08-26 23:56:00.000000000 +0200
  2. +++ sh.new.c    2010-08-27 00:02:46.000000000 +0200
  3. @@ -46,21 +46,21 @@
  4.     password = malloc(sizeof(char));
  5.     text = malloc(sizeof(char));
  6.     printf(">>> Username: ");
  7. -   i=0;
  8. -   while((username[i] = getchar())!='\n')
  9. -       username = realloc(username,sizeof(char)*++i);
  10. -   username[i] = '\0';
  11. +   l1=1;
  12. +   while((username[l1 - 1] = getchar())!='\n')
  13. +       username = realloc(username,sizeof(char)*++l1);
  14. +   username[l1 - 1] = '\0';
  15.     printf(">>> Password: ");
  16. -   i=0;
  17. -   while((password[i] = getchar())!='\n')
  18. -       password = realloc(password,sizeof(char)*++i);
  19. -   password[i] = '\0';
  20. -   i=0;
  21. +   l2=1;
  22. +   while((password[l2 - 1] = getchar())!='\n')
  23. +       password = realloc(password,sizeof(char)*++l2);
  24. +   password[l2 - 1] = '\0';
  25. +   i=1;
  26.     printf(">>> Text [CTRL-X + Return]:\n");
  27. -   while((text[i] = getchar())!=24) /* 24 == ctrl + x */
  28. -       if(text[i] != '\b')
  29. +   while((text[i - 1] = getchar())!=24) /* 24 == ctrl + x */
  30. +       if(text[i - 1] != '\b')
  31.         text = realloc(text,sizeof(char)*++i);
  32. -   text[i] = '\0';
  33. +   text[i - 1] = '\0';
  34.     use_text = 1;
  35.     printf("\n");
  36.      }
  37. @@ -69,10 +69,9 @@
  38.     username = strdup(argv[1]);
  39.     password = strdup(argv[2]);
  40.     use_text = 0;
  41. -    }
  42. -
  43.      l1 = strlen(username);
  44.      l2 = strlen(password);
  45. +    }
  46.  
  47.      user.sin_family = AF_INET;
  48.      user.sin_port = htons(80);
  49. @@ -150,7 +149,7 @@
  50.     fsize = ftell(fp);
  51.     rewind(fp);
  52.     buff = malloc(sizeof(char)*fsize);
  53. -   fread(buff,fsize,1,fp);
  54. +   fread(buff,1,fsize,fp);
  55.     buff[fsize-1]='\0';
  56.     fclose(fp);
  57.     len = MAX + fsize + 21;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement