- added some error checking
authorAndrew Tridgell <tridge@samba.org>
Sun, 30 Apr 2000 15:13:15 +0000 (15:13 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sun, 30 Apr 2000 15:13:15 +0000 (15:13 +0000)
 - removed the VTP hook in smbd

source/lib/util_file.c
source/libsmb/clirap.c
source/smbd/process.c

index c3b444ffa16880e4b8cce5aff8d784ed25a8dfb6..194fb7ae4970bd698690ab5ee91a56881acb225c 100644 (file)
@@ -353,7 +353,7 @@ char *file_pload(char *syscmd, size_t *size)
                memcpy(p+total, buf, n);
                total += n;
        }
-       p[total] = 0;
+       if (p) p[total] = 0;
 
        sys_pclose(fd);
 
index d918dcff5595e7879f2c61f65bfc07d25fdf04c0..5e7e9427f6f8fc167dee6925d6aa4cf752f46d41 100644 (file)
@@ -115,7 +115,7 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation)
                     &rparam, &rprcnt,               /* return params, return size */
                     &rdata, &rdrcnt                 /* return data, return size */
                    )) {
-               cli->rap_error = SVAL(rparam,0);
+               cli->rap_error = rparam? SVAL(rparam,0) : -1;
                p = rdata;
                
                if (cli->rap_error == 0) {
@@ -139,65 +139,66 @@ call a NetShareEnum - try and browse available connections on a host
 ****************************************************************************/
 int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *))
 {
-  char *rparam = NULL;
-  char *rdata = NULL;
-  char *p;
-  int rdrcnt,rprcnt;
-  pstring param;
-  int count = -1;
-
-  /* now send a SMBtrans command with api RNetShareEnum */
-  p = param;
-  SSVAL(p,0,0); /* api number */
-  p += 2;
-  pstrcpy(p,"WrLeh");
-  p = skip_string(p,1);
-  pstrcpy(p,"B13BWz");
-  p = skip_string(p,1);
-  SSVAL(p,0,1);
-  /*
-   * Win2k needs a *smaller* buffer than 0xFFFF here -
-   * it returns "out of server memory" with 0xFFFF !!! JRA.
-   */
-  SSVAL(p,2,0xFFE0);
-  p += 4;
-
-  if (cli_api(cli, 
-              param, PTR_DIFF(p,param), 1024,  /* Param, length, maxlen */
-              NULL, 0, 0xFFE0,            /* data, length, maxlen - Win2k needs a small buffer here too ! */
-              &rparam, &rprcnt,                /* return params, length */
-              &rdata, &rdrcnt))                /* return data, length */
-    {
-      int res = SVAL(rparam,0);
-      int converter=SVAL(rparam,2);
-      int i;
-      
-      if (res == 0 || res == ERRmoredata) {
-             count=SVAL(rparam,4);
-             p = rdata;
-
-             for (i=0;i<count;i++,p+=20) {
-                     char *sname = p;
-                     int type = SVAL(p,14);
-                     int comment_offset = IVAL(p,16) & 0xFFFF;
-                     char *cmnt = comment_offset?(rdata+comment_offset-converter):"";
-                         dos_to_unix(sname,True);
-                         dos_to_unix(cmnt,True);
-                     fn(sname, type, cmnt);
-             }
-      } else {
-             DEBUG(4,("NetShareEnum res=%d\n", res));
-      }      
-    } else {
-             DEBUG(4,("NetShareEnum failed\n"));
-    }
-  
-  if (rparam)
-    free(rparam);
-  if (rdata)
-    free(rdata);
+       char *rparam = NULL;
+       char *rdata = NULL;
+       char *p;
+       int rdrcnt,rprcnt;
+       pstring param;
+       int count = -1;
 
-  return count;
+       /* now send a SMBtrans command with api RNetShareEnum */
+       p = param;
+       SSVAL(p,0,0); /* api number */
+       p += 2;
+       pstrcpy(p,"WrLeh");
+       p = skip_string(p,1);
+       pstrcpy(p,"B13BWz");
+       p = skip_string(p,1);
+       SSVAL(p,0,1);
+       /*
+        * Win2k needs a *smaller* buffer than 0xFFFF here -
+        * it returns "out of server memory" with 0xFFFF !!! JRA.
+        */
+       SSVAL(p,2,0xFFE0);
+       p += 4;
+       
+       if (cli_api(cli, 
+                   param, PTR_DIFF(p,param), 1024,  /* Param, length, maxlen */
+                   NULL, 0, 0xFFE0,            /* data, length, maxlen - Win2k needs a small buffer here too ! */
+                   &rparam, &rprcnt,                /* return params, length */
+                   &rdata, &rdrcnt))                /* return data, length */
+               {
+                       int res = rparam? SVAL(rparam,0) : -1;
+                       
+                       if (res == 0 || res == ERRmoredata) {
+                               int converter=SVAL(rparam,2);
+                               int i;
+                               
+                               count=SVAL(rparam,4);
+                               p = rdata;
+                               
+                               for (i=0;i<count;i++,p+=20) {
+                                       char *sname = p;
+                                       int type = SVAL(p,14);
+                                       int comment_offset = IVAL(p,16) & 0xFFFF;
+                                       char *cmnt = comment_offset?(rdata+comment_offset-converter):"";
+                                       dos_to_unix(sname,True);
+                                       dos_to_unix(cmnt,True);
+                                       fn(sname, type, cmnt);
+                               }
+                       } else {
+                               DEBUG(4,("NetShareEnum res=%d\n", res));
+                       }      
+               } else {
+                       DEBUG(4,("NetShareEnum failed\n"));
+               }
+  
+       if (rparam)
+               free(rparam);
+       if (rdata)
+               free(rdata);
+       
+       return count;
 }
 
 
@@ -244,11 +245,12 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
                     &rparam, &rprcnt,                   /* return params, return size */
                     &rdata, &rdrcnt                     /* return data, return size */
                    )) {
-               int res = SVAL(rparam,0);
-               int converter=SVAL(rparam,2);
-               int i;
+               int res = rparam? SVAL(rparam,0) : -1;
                        
                if (res == 0 || res == ERRmoredata) {
+                       int i;
+                       int converter=SVAL(rparam,2);
+
                        count=SVAL(rparam,4);
                        p = rdata;
                                        
@@ -268,9 +270,9 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
        }
   
        if (rparam)
-      free(rparam);
+               free(rparam);
        if (rdata)
-      free(rdata);
+               free(rdata);
        
        return(count > 0);
 }
index f37855028295f4f836720333914f0ad8477c1529..b81e8311337f4762e4cb44a4f2c3749f873f2345 100644 (file)
@@ -631,14 +631,6 @@ void process_smb(char *inbuf, char *outbuf)
     }
 #endif  /* WITH_SSL */
 
-#ifdef WITH_VTP
-  if(trans_num == 1 && VT_Check(inbuf)) 
-  {
-    VT_Process();
-    return;
-  }
-#endif
-
   if (msg_type == 0)
     show_msg(inbuf);
   else if(msg_type == 0x85)