Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Format String  at pvmd.c:1738

Categories: MISC.FMT CWE:134
Warning ID: 22201.29376
Procedure: work
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/pvmd.c
  Enter work
1696 work() 
1697 {
1698         static int lastpinged = 0;      /* host that got last keepalive msg */ 
1699 #ifdef FDSETNOTSTRUCT 
1700         fd_set rfds, wfds;                      /* result of select */ 
1701         /* fd_set efds; */ 
1702 #else 
1703         struct fd_set rfds, wfds;       /* result of select */ 
1704         /* struct fd_set efds; */ 
1705 #endif 
1706         int nrdy;                                       /* number of fds ready after select */ 
  ...
1718         double tbpl;                            /* time at beginning of probe loop */ 
1719         double toutpl;                          /* timeout in the probe loop */ 
1720         int timed_out;
1721         extern double dclock();
1722 #endif 
1723 #endif 
1724 #ifdef  SHMEM 
1725         int someclosed; 
1726 #endif 
1727  
1728         gettimeofday(&tnow, (struct timezone*)0);
1729         if (pvmdebmask || myhostpart) {
1730                 PVM_TIMET time_temp;
1731                 pvmlogprintf("%s (%s) %s %s\n",
1732                                 hosts->ht_hosts[hosts->ht_local]->hd_name,
1733                                 inadport_decimal(&hosts->ht_hosts[hosts->ht_local]->hd_sad),   /* Buffer Overrun (ID: 22089.28936) */  /* Buffer Underrun (ID: 22088.28935) */
1734                                 myarchname,
1735                                 PVM_VER);
1736                 pvmlogprintf("ready ");
1737                 time_temp = (PVM_TIMET) tnow.tv_sec;
1738                 pvmlogprintf(ctime(&time_temp));     /* Format String */
1739         }
1740  
1741         /*
1742         * check for default plug-in modules (& start them)
1743         * (only if pvmd, not for pvmd'...)
1744         */ 
1745  
1746         if ( myhostpart ) {
1747                 char *av[5];
1748                 char *buf;
1749                 char *cmd;
1750                 int ac;
1751                 int i;
1752  
1753                 for ( i=0 ; modulenames[i] ; i++ ) {
1754                         cmd = getenv( modulenames[i] );
1755                         if ( cmd != NULL )
1756                         {
1757                                 buf = STRALLOC( cmd );   /* Null Pointer Dereference (ID: 99.28694) */
1758                                 ac = sizeof(av)/sizeof(av[0]);
1759                                 if (!buf || acav( buf, &ac, av )) {
1760                                         pvmlogprintf( "$%s: Line Too Long \"%s\".\n",
1761                                                         modulenames[i], cmd );
1762                                 } else {
1763                                         av[ ac ] = (char *) NULL;
1764                                         locl_spawn( av[0], av + 1 );
1765                                 }
1766                                 if (buf) PVM_FREE( buf );
1767                         }
1768                 }
1769         }
1770  
1771         /*
1772         * remind myself to start those pesky slave pvmds 
1773         */ 
1774  
1775         if (addmesg) {
1776                 struct pmsg *mp = addmesg;
1777  
1778                 addmesg = 0;
1779                 sendmessage(mp);
1780         }
1781  
1782         /*
1783         * init bail (for PVMDSTARTUP) and ping times 
1784         */ 
1785  
1786         pvmgetclock(&tnow);
1787         tout.tv_sec = DDBAILTIME;
1788         tout.tv_usec = 0;
1789         TVXADDY(&tbail, &tnow, &tout);
1790  
1791         tout.tv_sec = DDPINGTIME;
1792         tout.tv_usec = 0;
1793         TVXADDY(&tping, &tnow, &tout);
1794  
1795         /* init select fd sets */ 
1796  
1797         wrk_fds_init();
1798  
1799         if (loclsock >= 0)
1800                 wrk_fds_add(loclsock, 1);
1801         wrk_fds_add(netsock, 1);
1802  
1803         for (; ; ) {
1804  
1805                 /*
1806                 *       clean up after any tasks that we got SIGCHLDs for 
1807                 */ 
1808 #ifdef IMA_BEOSCYLD 
1809                 reap(SIGCLD); 
1810 #endif 
1811                 while (rdead != wdead) {
1812                         if (deads[rdead].dd_pid == pprime) {
1813                                 int cc;
1814 #ifdef SOCKLENISUINT 
1815 #if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2) \
1816                 || defined(IMA_AIX56K64) || defined(IMA_LINUXALPHA)
1817                                 unsigned int oslen;
1818 #else 
1819                                 size_t oslen;
1820 #endif 
1821 #else 
1822                                 int oslen;
1823 #endif 
1824                                 struct sockaddr_in osad;
1825                                 struct timeval t;
1826                                 char buf[DDFRAGHDR];
1827  
1828                                 hostfailentry(hosts->ht_hosts[0]);
1829                                 clear_opq_of((int)(TIDPVMD | hosts->ht_hosts[0]->hd_hostpart));
1830                                 pprime = 0;
1831  
1832                                 while (1) {
1833                                         FD_ZERO(&rfds);
1834                                         FD_SET(ppnetsock, &rfds);
1835                                         t.tv_sec = 0;
1836                                         t.tv_usec = 0;
1837                                         cc = select(ppnetsock + 1,
1838 #ifdef  FDSETISINT 
1839                                                         (int *)&rfds, (int *)0, (int *)0, 
1840 #else 
1841                                                         (fd_set *)&rfds, (fd_set *)0, (fd_set *)0,
1842 #endif 
1843                                                         &t);
1844                                         if (cc == 1) {
1845                                                 oslen = sizeof(osad);
1846                                                 recvfrom(ppnetsock, buf, sizeof(buf),
1847                                                                 0, (struct sockaddr*)&osad, &oslen);
1848  
1849                                         } else if (cc != -1 || errno != EINTR)
1850                                                 break;
1851                                 }
1852  
1853                         } else {
1854                                 if (tp = task_findpid(deads[rdead].dd_pid)) {
1855  
1856                 /* check for output one last time 
1857                    XXX this could be cleaner by going through main select again 
1858                    XXX before flushing the task */ 
1859  
1860                                         tp->t_status = deads[rdead].dd_es;
1861                                         tp->t_utime = deads[rdead].dd_ut;
1862                                         tp->t_stime = deads[rdead].dd_st;
1863                                         while (tp->t_out >= 0) {
1864  
1865 #ifdef FDSETNOTSTRUCT 
1866                                                 fd_set rfds;
1867 #else 
1868                                                 struct fd_set rfds; 
1869 #endif 
1870  
1871                                                 FD_ZERO(&rfds);
1872                                                 FD_SET(tp->t_out, &rfds);
1873                                                 TVCLEAR(&tout);
1874                                                 if (select(tp->t_out + 1,
1875 #ifdef  FDSETISINT 
1876                                                                 (int *)&rfds, (int *)0, (int *)0, 
1877 #else 
1878                                                                 (fd_set *)&rfds, (fd_set *)0, (fd_set *)0,
1879 #endif 
1880                                                                 &tout) == 1)
1881                                                         loclstout(tp);
1882  
1883                                                 else 
1884                                                         break;
1885                                         }
1886 #if defined(IMA_PGON) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
1887         || defined(IMA_AIX5SP2) || defined(IMA_BEOLIN) 
1888                                         mpp_free(tp); 
1889 #endif 
1890                                         task_cleanup(tp);
1891                                         task_free(tp);
1892                                 }
1893                         }
1894                         if (++rdead >= ndead)
1895                                 rdead = 0;
1896                 }
1897  
1898                 netoutput();
1899  
1900                 if (runstate == PVMDHALTING) {
1901                         pvmlogerror("work() pvmd halting\n");
1902                         pvmbailout(0);
1903                 }
1904  
1905                 /* bail if new slave and haven't been configured for too long */ 
1906                 pvmgetclock(&tnow);
1907                 if (runstate == PVMDSTARTUP && TVXLTY(&tbail, &tnow)) {
1908                         pvmlogerror("work() run = STARTUP, timed out waiting for master\n");
1909                         pvmbailout(0);
1910                 }
1911  
1912                 /*
1913                 * send keepalive message to remote pvmd once in a while 
1914                 */ 
1915                 if (TVXLTY(&tping, &tnow)) {
1916                         if (pvmdebmask & (PDMPACKET|PDMSELECT))
1917                                 pvmlogerror("work() ping timer\n");
1918                         if (runstate == PVMDNORMAL || runstate == PVMDHTUPD) {
1919                                 do {
1920                                         if (++lastpinged > hosts->ht_last)
1921                                                 lastpinged = 1;
1922                                 } while (!(hp = hosts->ht_hosts[lastpinged]));
1923  
1924                                 if (hp->hd_hostpart != myhostpart 
1925                                 && hp->hd_txq->pk_link == hp->hd_txq) {
1926                                         mp = mesg_new(0);
1927                                         mp->m_tag = DM_NULL;   /* Null Pointer Dereference (ID: 98.28691) */
1928                                         mp->m_dst = hp->hd_hostpart | TIDPVMD;
1929                                         sendmessage(mp);
1930                                 }
1931                         }
1932                         tout.tv_sec = DDPINGTIME;
1933                         tout.tv_usec = 0;
1934                         TVXADDY(&tping, &tnow, &tout);
1935                 }
1936  
1937                 /*
1938                 * figure select timeout 
1939                 */ 
1940  
1941                 if (opq->pk_tlink == opq)
1942                         tout = tping;
1943                 else 
1944                         tout = opq->pk_tlink->pk_rtv;   /* Use After Free (ID: 22033.28690) */
1945  
1946                 if (TVXLTY(&tout, &tnow)) {
1947                         TVCLEAR(&tout);
1948  
1949                 } else {
1950                         TVXSUBY(&tout, &tout, &tnow);
1951                 }
1952  
1953                 if (pvmdebmask & PDMSELECT) {
1954                         pvmlogprintf("work() select tout is %d.%06d\n",
1955                                         tout.tv_sec, tout.tv_usec);
1956                 }
1957  
1958  
1959 #ifdef SHMEM 
1960                 if ((nodemsg = mpp_probe()) == 1) {
1961                         mpp_input();
1962                         TVCLEAR(&tout);
1963                 } 
1964 #endif 
1965  
1966                 rfds = wrk_rfds;
1967                 wfds = wrk_wfds;
1968 /*
1969                 efds = wrk_efds;
1970 */ 
1971                 if (pvmdebmask & PDMSELECT) {
1972                         pvmlogprintf("work() wrk_nfds=%d\n", wrk_nfds);
1973                         print_fdset("work() rfds=", wrk_nfds, &rfds);
1974                         print_fdset("work() wfds=", wrk_nfds, &wfds);
1975                 }
1976  
1977 #if !defined(IMA_PGON) && !defined(IMA_I860)
1978  
1979                 if ((nrdy = select(wrk_nfds,
1980 #ifdef  FDSETISINT 
1981                                 (int *)&rfds, (int *)&wfds, (int *)0, 
1982 #else 
1983                                 (fd_set *)&rfds, (fd_set *)&wfds, (fd_set *)0,
1984 #endif 
1985                                 &tout)) == -1) {
1986                         if (errno != EINTR) {
1987                                 pvmlogperror("work() select");
1988                                 pvmlogprintf(" wrk_nfds=%d\n", wrk_nfds);
1989                                 print_fdset(" rfds=", wrk_nfds, &wrk_rfds);
1990                                 print_fdset(" wfds=", wrk_nfds, &wrk_wfds);
1991                                 pvmlogprintf(" netsock=%d, ppnetsock=%d, loclsock=%d\n",
1992                                                 netsock, ppnetsock, loclsock);
1993                                 task_dump();
1994                                 pvmbailout(0);
1995                         }
1996                 }
1997  
1998 #else /*IMA_PGON/IMA_I860*/ 
1999  
2000                 timed_out = 0;
2001                 toutpl = (double)tout.tv_sec + 1e-6*((double)tout.tv_usec);
2002                 tbpl = dclock();   /* use the pgon hw clock */ 
2003  
2004                 if (pvmdebmask & PDMSELECT) {
  ...
2054                         }
2055  
2056                         /* Try to send packets that are still on the mpp output q */ 
2057                         mpp_output( (struct task *) NULL, (struct pkt *) NULL);
2058  
2059                 } while(!(nrdy || nodemsg || timed_out)); 
2060  
2061 #endif /*IMA_PGON/IMA_I860*/ 
2062  
2063 #ifdef  STATISTICS 
2064                 switch (nrdy) {
2065                 case -1: 
2066                         stats.selneg++;
2067                         break;
2068                 case 0: 
2069                         stats.selzer++;
2070                         break;
2071                 default: 
2072                         stats.selrdy++;
2073                         break;
2074                 }
2075 #endif 
2076                 if (pvmdebmask & PDMSELECT) {
2077                         pvmlogprintf("work() SELECT returns %d\n", nrdy);
2078                 }
2079  
2080         /*
2081         *       check network socket and local master socket for action 
2082         */ 
2083  
2084                 if (nrdy > 0) {
2085                         if (FD_ISSET(netsock, &rfds)) {
2086                                 nrdy--;
2087                                 netinput();
2088                         }
2089                         if (loclsock >= 0 && FD_ISSET(loclsock, &rfds)) {
2090                                 nrdy--;
2091                                 loclconn();
2092                         }
2093                 }
2094  
2095         /*
2096         *       check tasks for action 
2097         */ 
2098  
2099 #ifdef  SHMEM 
2100                 someclosed = 0; 
2101 #endif 
2102                 if (loclsock >= 0) {
2103                         for (tp = locltasks->t_link;
2104                                         nrdy > 0 && tp != locltasks;
2105                                         tp = tp->t_link) {
2106  
2107                                 if (tp->t_sock >= 0 && FD_ISSET(tp->t_sock, &rfds)) {
2108                                         FD_CLR(tp->t_sock, &rfds);
2109                                         nrdy--;
2110                                         if (loclinput(tp)) {
2111 #ifdef  SHMEM 
2112                                                 if (tp->t_tid == 0)
2113                                                         someclosed++; 
2114 #endif 
2115                                                 if (pvmdebmask & PDMTASK) {
2116                                                         pvmlogprintf( 
2117                                                                         "work() error reading from t%x, marking dead\n",
2118                                                                         tp->t_tid);
2119                                                 }
2120                                                 if (!(tp->t_flag & TF_FORKD)) {
2121                                                         tp = tp->t_rlink;
2122                                                         task_cleanup(tp->t_link);
2123                                                         task_free(tp->t_link);
2124  
2125                                                 } else 
2126                                                         wrk_fds_delete(tp->t_sock, 3);
2127                                                 continue;
2128                                         }
2129                                 }
2130  
2131                                 if (tp->t_sock >= 0 && FD_ISSET(tp->t_sock, &wfds)) {
2132                                         FD_CLR(tp->t_sock, &wfds);
2133                                         nrdy--;
2134                                         if (locloutput(tp)) {
2135 #ifdef  SHMEM 
2136                                                 if (tp->t_tid == 0)
2137                                                         someclosed++; 
2138 #endif 
2139                                                 if (!(tp->t_flag & TF_FORKD)) {
2140                                                         tp = tp->t_rlink;
2141                                                         task_cleanup(tp->t_link);
2142                                                         task_free(tp->t_link);
2143  
2144                                                 } else 
2145                                                         wrk_fds_delete(tp->t_sock, 3);
2146                                                 continue;
2147                                         }
2148                                 }
2149  
2150                                 if (tp->t_out >= 0 && FD_ISSET(tp->t_out, &rfds)) {
2151                                         FD_CLR(tp->t_out, &rfds);
2152                                         nrdy--;
2153                                         loclstout(tp);
2154                                 }
2155                         }
2156                 }
2157 #if defined(IMA_CM5) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
2158         || defined(IMA_AIX5SP2) || defined(IMA_BEOLIN) 
2159                 mpp_output((struct task *)0, (struct pkt *)0); 
2160 #endif 
2161 #ifdef  SHMEM 
2162                 if (someclosed)
2163                         mpp_dredge(); 
2164 #endif 
2165         }
2166 } 




Change Warning 22201.29376 : Format String

Priority:
State:
Finding:
Owner:
Note: