Show
Ignore:
Timestamp:
11/11/08 00:16:55 (2 months ago)
Author:
common
Message:

libemu

  • gcc 4.3.2 enforces return value checks for (v)asprintf, system, f(read|write), in most cases (ran out of memory) we can just bail out with exit(-1)
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libemu/trunk/tools/sctest/userhooks.c

    r1706 r1707  
    251251                                dup2(err[0], fileno(stderr)); 
    252252 
     253                                int sys = -1; 
    253254                                struct emu_hashtable_item *ehi = emu_hashtable_search(opts.override.commands.commands, "cmd"); 
    254255                                if ( ehi != NULL ) 
    255                                         system((char *)ehi->value); 
     256                                        sys = system((char *)ehi->value); 
    256257                                else 
    257                                         system("/bin/sh -c \"cd ~/.wine/drive_c/; wine 'c:\\windows\\system32\\cmd_orig.exe' \""); 
     258                                        sys = system("/bin/sh -c \"cd ~/.wine/drive_c/; wine 'c:\\windows\\system32\\cmd_orig.exe' \""); 
    258259 
    259260                                close(in[1]); 
     
    261262                                close(err[0]); 
    262263 
    263                                 printf("process ended!\n"); 
     264                                printf("process ended (%i)!\n", sys); 
    264265                                exit(EXIT_SUCCESS); 
    265266                        } else 
     
    291292                                        int action = select(highsock+1, &socks, NULL, NULL, &timeout); 
    292293//                                      printf("select %i\n",action); 
    293  
     294                                        int written = -1; 
    294295                                        if ( action > 0 ) 
    295296                                        { 
     
    297298                                                { 
    298299                                                        int size = read(psiStartInfo->hStdInput, buf, 1024); 
     300                                                         
    299301//                                                      printf("read %i in '%.*s'\n",size,size,buf); 
    300302                                                        if ( size > 0 ) 
    301                                                                 write(in[0], buf, size); 
     303                                                                written = write(in[0], buf, size); 
    302304                                                        else 
    303305                                                                goto exit_now; 
     
    309311//                                                      printf("read %i out '%.*s'\n",size,size,buf); 
    310312                                                        if ( size > 0 ) 
    311                                                                 write(psiStartInfo->hStdOutput, buf, size); 
     313                                                                written = write(psiStartInfo->hStdOutput, buf, size); 
    312314                                                        else 
    313315                                                                goto exit_now; 
     
    319321//                                                      printf("read %i err '%.*s'\n",size,size,buf); 
    320322                                                        if ( size > 0 ) 
    321                                                                 write(psiStartInfo->hStdOutput, buf, size); 
     323                                                                written = write(psiStartInfo->hStdOutput, buf, size); 
    322324                                                        else 
    323325                                                                goto exit_now; 
     
    539541 
    540542        char *localfile; 
    541         asprintf(&localfile, "/tmp/%s-XXXXXX",filename); 
     543 
     544        if ( asprintf(&localfile, "/tmp/%s-XXXXXX",filename) == -1) 
     545                exit(-1); 
     546 
    542547        int fd = mkstemp(localfile); 
    543548        close(fd); 
     
    697702 
    698703        char *localfile; 
    699         asprintf(&localfile, "/tmp/%s-XXXXXX",lpFileName); 
     704 
     705        if ( asprintf(&localfile, "/tmp/%s-XXXXXX",lpFileName) == -1) 
     706                exit(-1); 
     707 
    700708        int fd = mkstemp(localfile); 
    701709        close(fd); 
     
    723731*/ 
    724732 
     733        int written = -1; 
    725734        va_list vl; 
    726735        va_start(vl, hook); 
     
    735744 
    736745        if (nf != NULL) 
    737                 fwrite(lpBuffer, nNumberOfBytesToWrite, 1, nf->real_file); 
     746                written = fwrite(lpBuffer, nNumberOfBytesToWrite, 1, nf->real_file); 
    738747        else 
    739748                printf("shellcode tried to write data to not existing handle\n");