Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Null Pointer Dereference  at tdpro.c:864

Categories: LANG.MEM.NPD CWE:476
Warning ID: 2699.2752
Procedure: tm_conn2
Trace: View
Modified: Wed Sep 2 12:44:00 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     
ProblemLineSource
   /u1/paul/SATE/2010/c/pvm/pvm3/src/tdpro.c
   Enter tm_conn2
 670 tm_conn2(tp, mp) 
 671         struct task *tp;
 672         struct pmsg *mp;
 673 {
 674         int tid;
 675         int pid;                                                /* real pid of task */ 
 676         int cookie;                                             /* cookie to identify task or 0 */ 
 677         struct task *tp2;                               /* to search for existing context */ 
 678         struct pmsg *mp2;
 679         int cc;
 680         char c;
 681         char *taskname = (char *) NULL;
 682  
 683         if (upkint(mp, &pid) || upkint(mp, &cookie)) {
 684                 pvmlogerror("tm_conn2() bad msg format\n");
 685                 goto bail;
 686         }
 687         if (!cookie)
 688                 cookie = pid;
 689  
 690         if (!(tp->t_flag & TF_AUTH)) {
 691                 pvmlogprintf("tm_conn2() message from t%x, TF_AUTH not set\n",
 692                                 tp->t_tid);
 693                 return 0;
 694         }
 695  
 696         /*
 697         *       check that task could write d-auth file 
 698         */ 
 699  
 700 #ifndef NOPROT 
 701  
 702         if ((cc = read(tp->t_authfd, &c, 1)) == -1) {
 703                 pvmlogperror("tm_conn2() can't read d-auth file");
 704                 return 0;
 705         }
 706  
 707         if (cc != 1) {
 708                 pvmlogerror("tm_conn2() task didn't validate itself\n");
 709                 goto bail;
 710         }
 711  
 712         (void)close(tp->t_authfd);
 713         tp->t_authfd = -1;
 714         (void)unlink(tp->t_authnam);
 715  
 716 #endif 
 717  
 718         PVM_FREE(tp->t_authnam);
 719         tp->t_authnam = 0;
 720  
 721         /*
 722         *       if task spawned by us, already has a context,
 723         *       else make it one 
 724         */ 
 725  
 726         if ((tp2 = task_findpid(cookie)) && !(tp2->t_flag & (TF_AUTH|TF_CONN))) {
 727                 if (pvmdebmask & PDMTASK) {
 728                         pvmlogprintf("tm_conn2() reconnect task t%x\n", tp2->t_tid);
 729                 }
 730                 tp->t_sched = tp2->t_sched;
 731  
 732 #ifdef IMA_BEOLIN 
 733         } else if ( (tp2 = mpp_conn(tp))
 734                         && !(tp2->t_flag & (TF_AUTH|TF_CONN)) ) {
 735                 if (pvmdebmask & PDMTASK) {
 736                         pvmlogprintf(
 737                                         "tm_conn2() reconnect task t%x pid=%d name=%s\n",
 738                                         tp2->t_tid,tp2->t_pid, tp2->t_a_out );
 739                 } 
 740 #endif 
 741  
 742         } else {
 743                 if ((tid = tid_new()) < 0) {
 744                         pvmlogerror("tm_conn2() out of tids?\n");
 745                         goto bail;              /* XXX should disconnect nicely */ 
 746                 }
 747                 if ((tp2 = task_new(tid)) == NULL) {
 748                         pvmlogerror("tm_conn2() too many tasks?\n");
 749                         goto bail;              /* XXX should disconnect nicely */ 
 750                 }
 751  
 752                 if ( !upkstralloc(mp, &taskname) ) {
 753                         tp2->t_a_out = taskname;
 754                 }
 755  
 756                 if (pvmschedtid) {
 757                         /* inform the scheduler about the new task */ 
 758  
 759                         tp->t_sched = pvmschedtid;
 760                         mp2 = mesg_new(0);
 761                         pkint(mp2, 1);
 762                         pkint(mp2, tid);
 763                         mp2->m_tag = SM_EXECACK;                /* XXX yecch, overload */   /* Null Pointer Dereference (ID: 2700.2753) */
 764                         mp2->m_dst = pvmschedtid;
 765                         sendmessage(mp2);
 766                 }
 767  
 768                 /* check for tracer */ 
 769                 if (pvmtracer.trctid && pvmtracer.trctag) {
 770                         tp2->t_trctid = pvmtracer.trctid;
 771                         tp2->t_trcctx = pvmtracer.trcctx;
 772                         tp2->t_trctag = pvmtracer.trctag;
 773                         /* Note:  can't get the trace mask or trace buffer size 
 774                                 to task here, but this will be handled using mailbox */ 
 775  
 776                         /* trace start message */ 
 777                         /* XXX Note:  we don't really know if we should send this 
 778                                 because this task could have prohibited tracing 
 779                                 by setting PvmSelfTraceTid to -1... */ 
 780                         tev_send_newtask( 
 781                                 pvmtracer.trctid, pvmtracer.trcctx, pvmtracer.trctag,
 782                                 tid, -1, -1, tp->t_a_out ? tp->t_a_out : "-" );
 783                 }
 784                 if (pvmtracer.outtid && pvmtracer.outtag) {
 785                         tp2->t_outtid = pvmtracer.outtid;
 786                         tp2->t_outctx = pvmtracer.outctx;
 787                         tp2->t_outtag = pvmtracer.outtag;
 788  
 789                         /* output start message */ 
 790                         /* Note:  same deal here as for TEV_NEWTASK above... */ 
 791                         mp2 = mesg_new(0);
 792                         mp2->m_dst = pvmtracer.outtid;   /* Null Pointer Dereference (ID: 2701.2754) */
 793                         mp2->m_ctx = pvmtracer.outctx;
 794                         mp2->m_tag = pvmtracer.outtag;
 795                         pkint(mp2, tid);
 796                         pkint(mp2, TO_NEW);
 797                         pkint(mp2, -1);
 798                         sendmessage(mp2);
 799                 }
 800  
 801                 if (pvmdebmask & PDMTASK) {
 802                         pvmlogprintf("tm_conn2() new task t%x\n", tp2->t_tid);
 803                 }
 804         }
 805  
 806         /*
 807         *       brundle-fly the contexts together 
 808         */ 
 809  
 810         tp2->t_sock = tp->t_sock;
 811         tp2->t_sad = tp->t_sad;
 812         tp2->t_salen = tp->t_salen;
 813  
 814 #ifdef NOPROT 
 815         if (!TIDISNODE(tp2->t_tid)) {
 816                 if (pvmdebmask & PDMTASK) {
 817                         pvmlogprintf( "Setting pid of t%x to %d, same as t%x\n",
 818                                         tp2->t_tid, tp->t_pid, tp->t_tid );
 819                 }
 820                 task_setpid(tp2, tp->t_pid);
 821         } 
 822 #else 
 823         if (tp2->t_pid != pid)
 824                 task_setpid(tp2, pid);
 825 #endif 
 826  
 827         tp2->t_rxp = tp->t_rxp;
 828         tp2->t_sched = tp->t_sched;
 829         tp->t_sock = -1;        /* tp will be freed by loclinput() */ 
 830         tp->t_rxp = 0;
 831         tp = tp2;
 832         if (cookie != pid)
 833                 tp->t_flag &= ~TF_FORKD;
 834  
 835         /*
 836         *       kick it in the butt; it's ready to go 
 837         */ 
 838  
 839         tp->t_flag &= ~TF_AUTH;
 840         tp->t_flag |= TF_CONN;
 841  
true842         mp = replymessage(mp);
 843         pkint(mp, 1);
 844         pkint(mp, tp->t_tid);
 845         pkint(mp, tp->t_ptid);
 846         pkint(mp, tp->t_outtid);
 847         pkint(mp, tp->t_outctx);
 848         pkint(mp, tp->t_outtag);
 849         pkint(mp, tp->t_trctid);
 850         pkint(mp, tp->t_trcctx);
 851         pkint(mp, tp->t_trctag);
 852         pkint(mp, pvmudpmtu);
 853         pkint(mp, pvmmydsig);
 854 #ifdef IMA_BEOLIN 
 855         if (TIDISNODE(tp->t_tid))
 856                 /* on a node, use the address that came from nodeaddr[] */ 
 857                 pkstr(mp, inadport_hex(&(tp->t_sad)));
 858         else 
 859                 pkstr(mp, inadport_hex(&(hosts->ht_hosts[hosts->ht_local]->hd_sad))); 
 860 #else 
 861         pkstr(mp, inadport_hex(&(hosts->ht_hosts[hosts->ht_local]->hd_sad)));
 862 #endif 
 863         pkint(mp, pvmschedtid);
mp <= 4095864         mp->m_dst = tp->t_tid;     /* Null Pointer Dereference */
Preconditions
&$unknown_950394 != 0
&$unknown_950399 != 0
&$unknown_950432 = 0
&$unknown_950433 = 0
&$unknown_950434 = 0
&$unknown_950435 = 0
&freepmsgs.m_link = freepmsgs.m_link
((char*)$param_1)[128] = 0
((char*)$param_1)[120] >= 0
end != start
numfrags != 0
numpmsgs = -1
pvmschedtid != 0
pvmtracer.trctid != 0
pvmtracer.outtag != 0
pvmtracer.trctag != 0
pvmtracer.outtid != 0
$input_12 = 1
$input_468 = 0
Postconditions
freefrags.fr_link->fr_link->fr_rlink' = freefrags.fr_link->fr_rlink
freepmsgs.m_link->m_link->m_rlink' = freepmsgs.m_link->m_rlink
((char*)&((char*)$unknown_950397)[16])[24]' = ((char*)&$unknown_950397)[24]
((char*)&((char*)$unknown_950397)[24])[16]' = ((char*)&$unknown_950397)[16]
((char*)$unknown_950412)[8]' = ((char*)&$unknown_950412)[8]
freepmsgs.m_link->m_frag' = 0
freepmsgs.m_link->m_rlink' = freepmsgs.m_link
freefrags.fr_link->fr_rlink->fr_link' = freefrags.fr_link->fr_link
freepmsgs.m_link->m_rlink->m_link' = freepmsgs.m_link->m_link
((char*)$unknown_950412)[8]' = $unknown_950412
freepmsgs.m_link->m_link' = &freepmsgs.m_link
strlen(&$unknown_950397)' = strlen($param_1)
((char*)&$unknown_950397)[144]' = pvmtracer.outtid
((char*)&$unknown_950397)[148]' = pvmtracer.outctx
((char*)&$unknown_950397)[152]' = pvmtracer.outtag
((char*)&$unknown_950397)[156]' = pvmtracer.trctid
((char*)&$unknown_950397)[160]' = pvmtracer.trcctx
((char*)&$unknown_950397)[164]' = pvmtracer.trctag
((char*)&$unknown_950397)[168]' = pvmschedtid
((char*)&$unknown_950397)[44]' != &$unknown_950394
((char*)&$unknown_950397)[48]' = ((char*)$param_1)[48]
((char*)&$unknown_950397)[52]' = ((char*)$param_1)[52]
((char*)&$unknown_950397)[54]' = ((char*)$param_1)[54]
((char*)&$unknown_950397)[56]' = ((char*)$param_1)[56]
((char*)&$unknown_950397)[60]' = ((char*)$param_1)[60]
((char*)&$unknown_950397)[68]' = ((char*)$param_1)[68]
((char*)&$unknown_950397)[88]' = ((char*)$param_1)[88]
atnewline' = 0
c' = $input_484
strlen(&c)' = $input_468
cc' = 1
cookie' = &$unknown_950394
freepmsgs.m_link' = &freepmsgs.m_link
freepmsgs.m_rlink' = &freepmsgs.m_link
mp' = 0
mp2' = &$unknown_950412
numpmsgs' = 0
pid' = ((char*)&$unknown_950397)[44]'
taskname' = 0
tid' >= 0
tmbuf.tm_sec' = &$unknown_950422
tp' = &$unknown_950397
tp2' = &$unknown_950397




Change Warning 2699.2752 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: