Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Ignored Return Value  at hoster.c:961

Categories: LANG.FUNCS.IRV CWE:252 CWE:253 POW10:7
Warning ID: 568.29373
Procedure: phase1
Trace: view
Modified: Thu Nov 26 11:39:35 2009   show details
 
Priority: None
State: None
Finding: None
Owner: None
  edit properties

Legend [ X ]
Warning Location
Contributes
Parse Error
Other Warning
Two or More Loop Iterations
On Execution Path
Comment
Macro
Preprocessor
Include
Keyword
Preprocessed Away

Source  |  Language: C Hide Legend     
LineSource
  /kat0/fletcher/SATE/2010/pvm3/src/hoster.c
  Enter phase1
770 phase1(sp) 
771         struct slot *sp;
772 {
773         struct hst *hp;
774         char *hn;
775         char *av[32];                   /* for rsh args */ 
776         int ac;
777         char buf[512];
778         int pid = -1;                   /* pid of rsh */ 
779         char *p;
780  
781 #ifndef NOREXEC 
782         struct servent *se;
783         static u_short execport = 0;
784  
785         if (!execport) {
786                 if (!(se = getservbyname("exec", "tcp"))) {
787                         pvmlogprintf("phase1() can't getservbyname(): %s\n", "exec");
788                         pvmbailout(0);
789                 }
790                 execport = se->s_port;
791                 endservent();
792         }
793 #endif 
794  
795         hp = sp->s_hst;
796         hn = hp->h_name;
797         sp->s_rfd = sp->s_wfd = sp->s_efd = -1;
798  
799         /*
800         * XXX manual startup hack... this is if we can't use rexec or rsh 
801         */ 
802  
803         if (hp->h_flag & HST_MANUAL) {
804                 fprintf(stderr, "*** Manual startup ***\n");
805                 fprintf(stderr, " to \"%s\" and type:\n", hn);
806  
807                 if (hp->h_wincmd) {
808                         fprintf(stderr, "%s\n\n", hp->h_cmd);
809                         fprintf(stderr, "or, if that command fails, " );
810                         fprintf(stderr, "for WIN32 hosts try:\n");
811                         fprintf(stderr, "%s\n\n", hp->h_wincmd);
812                 }
813                 else 
814                         fprintf(stderr, "%s\n", hp->h_cmd);
815  
816         /* get version */ 
817  
818                 fprintf(stderr, "Type response: ");
819                 fflush(stderr);
820                 if (!(fgets(buf, sizeof(buf), stdin))) {
821                         pvmlogprintf("host %s read error\n", hn);
822                         goto oops;
823                 }
824                 p = buf + strlen(buf) - 1;
825                 if (*p == '\n')
826                         *p = 0;
827                 hp->h_result = STRALLOC(buf);   /* Null Pointer Dereference (ID: 74.28661) */
828  
829         /* send vmid, if set */ 
830  
831                 if (hp->h_vmid) {
832                         fprintf(stderr, "Now Type the Virtual Machine ID on %s:\n",
833                                         hn);
834                         fprintf(stderr, "%s\n", hp->h_vmid);
835                 }
836  
837         /* done */ 
838  
839                 fprintf(stderr, "Thanks\n");
840                 fflush(stderr);
841                 return 0;
842         }
843  
844         /*
845         * XXX end manual startup hack 
846         */ 
847  
848         if (!(hp->h_flag & HST_PASSWORD)) {             /* use rsh to start */ 
849                 int wpfd[2], rpfd[2], epfd[2];
850                 int i;
851  
852                 if (pvmdebmask & PDMSTARTUP) {
853                         pvmlogprintf("phase1() trying rsh to %s\n", hn);
854                 }
855  
856         /* fork an rsh to startup the slave pvmd */ 
857  
858 #ifdef  IMA_TITN 
859                 if (socketpair(AF_UNIX, SOCK_STREAM, 0, wpfd) == -1 
860                 || socketpair(AF_UNIX, SOCK_STREAM, 0, rpfd) == -1 
861                 || socketpair(AF_UNIX, SOCK_STREAM, 0, epfd) == -1) {
862                         pvmlogperror("phase1() socketpair");
863                         goto oops;
864                 } 
865 #else 
866                 if (pipe(wpfd) == -1 || pipe(rpfd) == -1 || pipe(epfd) == -1) {
867                         pvmlogperror("phase1() pipe");
868                         goto oops;
869                 }
870 #endif 
871  
872                 if (pvmdebmask & PDMSTARTUP) {
873                         pvmlogprintf("phase1() pipes: %d %d %d %d %d %d\n",
874                                         wpfd[0], wpfd[1], rpfd[0], rpfd[1], epfd[0], epfd[1]);
875                 }
876  
877                 if ((pid = fork()) == -1) {
878                         pvmlogperror("phase1() fork");
879                         pvmbailout(0);
880                 }
881                 if (!pid) {
882                         (void)dup2(wpfd[0], 0);
883                         (void)dup2(rpfd[1], 1);
884                         (void)dup2(epfd[1], 2);
885                         for (i = getdtablesize(); --i > 2; )
886                                 (void)close(i);
887                         ac = 0;
888                         av[ac++] = pvmgetrsh();
889                         av[ac++] = hn;
890                         if (hp->) {
891                                 av[ac++] = "-l";
892                                 av[ac++] = hp->;
893                         }
894 #ifdef IMA_BEOSCYLD 
895                         /* Chop up the command line and all its parameters into 
896                          * individual strings. The underlying assumption here is 
897                          * that PVM_RSH is defined to specify 'bpsh' instead of 
898                          * 'rsh/ssh'. This bit of code converts the single string 
899                          * av[2] from this: "pvmd3 -option1 -option2", into this:
900                          * av[2] = "pvmd3", av[3] = "-option1", av[4] = "-option2").
901                          * If this is not done 'bpsh' treats the original av[2] as 
902                          * the file name of the command to be executed, which will 
903                          * fail to execute.
904                          */ 
905                         p = hp->h_cmd;
906                         do {
907                                 av[ac++] = p;
908                                 p = strstr(p," ");
909                                 if (p != NULL)
910                                         *p++ = '\0';
911                         } while (p != NULL); 
912 #else 
913                         av[ac++] = hp->h_cmd;
914 #endif 
915                         av[ac++] = 0;
916                         if (pvmdebmask & PDMSTARTUP) {
917                                 for (ac = 0; av[ac]; ac++)
918                                         fprintf(stderr, "av[%d]=\"%s\" ", ac, av[ac]);
919                                 fputc('\n', stderr);
920                         }
921                         execvp(av[0], av);
922                         fputs("phase1() execvp failed\n", stderr);
923                         fflush(stderr);
924                         _exit(1);
925                 }
926                 (void)close(wpfd[0]);
927                 (void)close(rpfd[1]);
928                 (void)close(epfd[1]);
929                 sp->s_wfd = wpfd[1];
930                 sp->s_rfd = rpfd[0];
931                 sp->s_efd = epfd[0];
932  
933         } else {                /* use rexec to start */ 
934  
935 #ifdef NOREXEC 
936                 pvmlogprintf("slconfg() PVM was built without rexec support, can't take passwords\n");
937                 goto oops; 
938 #else 
939                 if (pvmdebmask & PDMSTARTUP) {
940                         pvmlogprintf("phase1() rexec \"%s\"\n", hp->h_cmd);
941                 }
942                 if ((sp->s_wfd = sp->s_rfd = rexec(&hn, execport,
943                                 (hp-> ? hp-> : username),
944                                 (char*)0, hp->h_cmd, &sp->s_efd)) 
945                 == -1) {
946                         pvmlogprintf("phase1() rexec failed for host %s\n", hn);
947                         goto oops;
948                 }
949 #endif 
950         }
951  
952         /* send vmid, if set */ 
953         if (sp->s_hst->h_vmid && sp->s_wfd >= 0) {
954 #ifdef WIN32 
955                 win32_write_socket(sp->s_wfd, "PVM_VMID=", 9);
956                 win32_write_socket(sp->s_wfd,
957                                 sp->s_hst->h_vmid, strlen(sp->s_hst->h_vmid));
958                 win32_write_socket(sp->s_wfd, "\n", 1); 
959 #else 
960                 write(sp->s_wfd, "PVM_VMID=", 9);   /* Ignored Return Value (ID: 569.29374) */
961                 write(sp->s_wfd, sp->s_hst->h_vmid, strlen(sp->s_hst->h_vmid));     /* Ignored Return Value */
962                 write(sp->s_wfd, "\n", 1);   /* Ignored Return Value (ID: 567.29372) */
963 #endif 
964         }
965  
966         return 0;
967  
968 oops: 
969         hp->h_result = STRALLOC("PvmCantStart");   /* Null Pointer Dereference (ID: 75.28662) */
970         if (sp->s_wfd != -1)
971                 close(sp->s_wfd);
972         if (sp->s_rfd != -1)
973                 close(sp->s_rfd);
974         if (sp->s_efd != -1)
975                 close(sp->s_efd);
976         sp->s_wfd = sp->s_rfd = sp->s_efd = -1;
977         return 1;
978 } 




Change Warning 568.29373 : Ignored Return Value

Priority:
State:
Finding:
Owner:
Note: