Няшная / Говнокод #23203 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
int main()
{
  FILE *popen_result;
  char buff[512];
  char *cmd = "lss";
  int temperr = dup(2);               // copy where stderr is at the moment
  freopen("/dev/null", "w", stderr);  // trash stderr reports from popen shell
  popen_result = popen(cmd, "r");
  if( popen_result==NULL )
      printf("Error!\n");
  stderr = fdopen(temperr,"w");       // get back stderr
  perror(cmd);
  if ( feof(popen_result) )
    printf("Already at EOF!\n");
  if ( ferror(popen_result) )
    printf("Already at error!\n");
  int err=1;
  while(fgets(buff, sizeof(buff), popen_result)!=NULL){
        printf(">>> %s", buff);
        err=0;
  }
  if( err==1 )
      printf("Error! Command %s not found\n", cmd);
  if( feof(popen_result) && err==0)
      printf("EOF cmd\n");
  pclose(popen_result);
}

Хакерские манипуляции часто бывают бесполезны

Запостил: ProgRamistYshka ProgRamistYshka, (Updated )

Комментарии (0) RSS

Добавить комментарий

Из-за тебя ушел bormand, guest!

    А не использовать ли нам bbcode?


    8