Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Buffer Overrun  at lpvm.c:2897

Categories: LANG.MEM.BO CWE:120 CWE:121 CWE:122 CWE:126
Warning ID: 2748.2803
Procedure: mksocs
Trace: View
Modified: Wed Sep 2 12:44:52 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/lpvm.c
   Enter mksocs
$input_62748 > 1072792 mksocs() 
 2793 {
 2794         char buf[128];
 2795 #ifndef WIN32 
 2796         int d;
 2797 #else 
 2798         HANDLE d; 
 2799 #endif 
 2800  
 2801 #ifdef SOCKLENISUINT 
 2802 #if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2)
   ...
 2807 #else 
 2808         int oslen;
 2809 #endif 
 2810         int n;
 2811         int try;
 2812         char *p;
 2813 #ifndef NOUNIXDOM 
 2814         struct sockaddr_un uns;
 2815 #endif 
 2816  
$input_62756 > 1072817         if (topvmd)
 2818                 return 0;
 2819  
 2820         /*
 2821         * get addr of pvmd, make socket to talk.
 2822         * first try envar PVMSOCK, then try sockaddr file.
 2823         */ 
 2824  
$input_62764 > 1072825         if (!(p = getenv("PVMSOCK"))) {
$input_62796 > 1072826                 if (!(p = pvmdsockfile())) {   /* Redundant Condition (ID: 2746.2801) */
 2827                         pvmlogerror("mksocs() pvmdsockfile() failed\n");   /* Unreachable Call (ID: 2747.2802) */
 2828                         goto bail;
 2829                 }
 2830 #ifndef WIN32 
 2831                 if ((d = open(p, O_RDONLY, 0)) == -1) {
 2832 #else  
 2833                 d = win32_open_file(p);
 2834                 if (d == (HANDLE) -2) {
 2835                         system_loser_win=TRUE;
 2836                         d = (HANDLE) _open(p,O_RDONLY,0);
 2837                 }
 2838                 if (d== (HANDLE) -1) { 
 2839 #endif 
 2840                         pvmlogperror(p);
 2841                         goto bail;
   ...
 2843 #ifdef WIN32 
 2844                 if (!system_loser_win) {
 2845                         n = win32_read_file(d,buf,sizeof(buf));
 2846                         win32_close_file(d);
 2847                 }
 2848                 else  {
 2849                         n = (int)_read((int)d, (void *)buf, (unsigned int)sizeof(buf));
 2850                         (void)_close((int)d);
 2851                 } 
 2852 #else 
$input_12 > 1072853                 n = read(d, buf, sizeof(buf));
 2854                 (void)close(d);
 2855 #endif 
 2856                 if (n == -1) {
 2857                         pvmlogperror("mksocs() read addr file");
 2858                         goto bail;
 2859                 }
 2860                 if (n == 0) {
 2861                         pvmlogerror("mksocs() read addr file: wrong length read\n");
 2862                         goto bail;
 2863                 }
n > 1072864                 buf[n] = 0;   /* Buffer Overrun (ID: 2750.2805) */
strlen(&buf[0]) > 1072865                 p = buf;
 2866         }
 2867  
 2868         FD_ZERO(&pvmrfds);
 2869 /*
 2870         FD_ZERO(&pvmwfds);
 2871 */ 
 2872         pvmnfds = 0;
 2873  
 2874         topvmd = ttpcb_new();
 2875         topvmd->tt_tid = TIDPVMD;   /* Null Pointer Dereference (ID: 2749.2804) */
 2876  
 2877         if (p[0] == '/') {
 2878 #ifdef NOUNIXDOM 
 2879                 pvmlogerror("mksocs() no support for Unix domain socket\n");
 2880                 goto bail; 
 2881  
 2882 #else /*NOUNIXDOM*/ 
 2883                 if ((topvmd->tt_fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
 2884                         pvmlogperror("mksocs() socket");
 2885                         goto bail;
 2886                 }
 2887  
 2888         /*
 2889         * XXX these 2 loops are a hack -
 2890         * XXX it keeps too many tasks from overflowing the pvmd listen q.
 2891         * XXX maybe the pvmd should make a socket pair for the task instead.
 2892         */ 
 2893                 try = 5;
 2894                 while (1) {
 2895                         BZERO((char*)&uns, sizeof(uns));
 2896                         uns.sun_family = AF_UNIX;
strlen(p) > 1072897                         strcpy(uns.sun_path, p);     /* Buffer Overrun */
 2898                         n = sizeof(uns);
 2899                         if (connect(topvmd->tt_fd, (struct sockaddr*)&uns, n) == -1) {
 2900                                 if (--try <= 0) {
 2901                                         pvmlogperror("mksocs() connect");
 2902                                         pvmlogprintf("\tsocket address tried: %s\n",p);
 2903                                         goto bail;
 2904                                 }
 2905                                 pvmsleep(1);    /* XXX hmm again */ 
Preconditions
&$unknown_1212758 = &$unknown_1212757 + 136
&$unknown_1212758 >= 4232
numpmsgs = 0
$input_12 >= 0
$input_62844 <= 128
$input_62844 >= 1
td = 0
topvmd = 0
Postconditions
((char*)$unknown_1212757)[8]' = &$unknown_1212758
_ALARM_CLOCK' = 1
__arr' = &pvmrfds.__fds_bits[0]
__i' = 16
strlen(&$unknown_1212757)' = 0
((char*)&$unknown_1212757)[16]' = 0
((char*)&$unknown_1212757)[32]' = 0
((char*)&$unknown_1212757)[40]' = 1
((char*)&$unknown_1212757)[44]' = 0
((char*)&$unknown_1212757)[48]' = 0
((char*)&$unknown_1212757)[52]' = 0
((char*)&$unknown_1212757)[56]' = 0
((char*)&$unknown_1212757)[60]' = 0
((char*)&$unknown_1212757)[64]' = 0
((char*)&$unknown_1212757)[68]' = 0
((char*)&$unknown_1212757)[72]' = 0
((char*)&$unknown_1212757)[76]' = 0
((char*)&$unknown_1212757)[80]' = 0
((char*)&$unknown_1212757)[84]' = 0
$unknown_1212758' = &freepmsgs.m_link
((char*)&$unknown_1212758)[8]' = ((char*)&$unknown_1212757)[8]
buf[0]' = 47
buf[0]' is opened
strlen(&buf[0])' = $input_62844
d' = &$heap_163234 - 4096
errno' != 0
freepmsgs.m_link' = &$unknown_1212757
freepmsgs.m_rlink' = &$unknown_1212757 + 136
bytes_after(&$heap_163233)' = $input_12 + 1
$heap_163233' is allocated by malloc
$heap_163233' is a non-heap object
bytes_before(&$heap_163233)' = 0
strlen(&$heap_163233)' = $input_12
$heap_163234' is allocated by open
$heap_163235' = 0
bytes_after(&$heap_163235)' = 88
$heap_163235' is allocated by malloc
$heap_163235' is allocated
bytes_before(&$heap_163235)' = 0
strlen(&$heap_163235)' = 0
((char*)&$heap_163235)[24]' = &$heap_163236 - 4096
((char*)&$heap_163235)[64]' = &$unknown_1212757
$heap_163236' is allocated by open
$heap_163236' is allocated
((char*)&$heap_163236)[-4096]' is open
((char*)&$heap_163236)[-4096]' is initialized
n' = 110
numpmsgs' = 49
p' = &buf[0]
pvmnfds' = 0
pvmrfds.__fds_bits[15]' = 0
td' = &$heap_163233
topvmd' = &$heap_163235
uns.sun_family' = 1
strlen(&uns.sun_family)' = 0
uns.sun_path[0]' = 47




Change Warning 2748.2803 : Buffer Overrun

Priority:
State:
Finding:
Owner:
Note: