Fixed mainly signed/unsigned issues found by SGI cc in -fullwarn mode.
authorJeremy Allison <jra@samba.org>
Wed, 21 Oct 1998 16:58:34 +0000 (16:58 +0000)
committerJeremy Allison <jra@samba.org>
Wed, 21 Oct 1998 16:58:34 +0000 (16:58 +0000)
smbd/chgpasswd.c: Fixed (my) stupid bug where I was returning stack based variables. Doh !
smbd/trans2.c: Allows SETFILEINFO as well as QFILEINFO on directory handles.
Jeremy.

source/include/proto.h
source/rpc_client/cli_pipe.c
source/rpc_client/cli_samr.c
source/rpc_parse/parse_samr.c
source/rpc_server/srv_util.c
source/rpcclient/cmd_netlogon.c
source/rpcclient/cmd_samr.c
source/smbd/chgpasswd.c
source/smbd/ipc.c
source/smbd/password.c
source/smbd/trans2.c

index 206c1b309a42a7204283ed90976cbbdedd7b7a23..83848e45e7bab9c0c458588aab2a5d33aaa9ebbd 100644 (file)
@@ -1277,8 +1277,8 @@ BOOL get_samr_query_userinfo(struct cli_state *cli,
                                uint32 user_rid, SAM_USER_INFO_21 *usr);
 BOOL do_samr_chgpasswd_user(struct cli_state *cli,
                char *srv_name, char *user_name,
-               char nt_newpass[516], char nt_oldhash[16],
-               char lm_newpass[516], char lm_oldhash[16]);
+               char nt_newpass[516], uchar nt_oldhash[16],
+               char lm_newpass[516], uchar lm_oldhash[16]);
 BOOL do_samr_unknown_38(struct cli_state *cli, char *srv_name);
 BOOL do_samr_unknown_8(struct cli_state *cli, 
                                POLICY_HND *domain_pol, uint16 switch_value);
@@ -1750,12 +1750,12 @@ void make_samr_r_unknown_38(SAMR_R_UNKNOWN_38 *r_u);
 void samr_io_r_unknown_38(char *desc,  SAMR_R_UNKNOWN_38 *r_u, prs_struct *ps, int depth);
 void make_enc_passwd(SAMR_ENC_PASSWD *pwd, char pass[512]);
 void samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD *pwd, prs_struct *ps, int depth);
-void make_enc_hash(SAMR_ENC_HASH *hsh, char hash[16]);
+void make_enc_hash(SAMR_ENC_HASH *hsh, uchar hash[16]);
 void samr_io_enc_hash(char *desc, SAMR_ENC_HASH *hsh, prs_struct *ps, int depth);
 void make_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u,
                                char *dest_host, char *user_name,
-                               char nt_newpass[516], char nt_oldhash[16],
-                               char lm_newpass[516], char lm_oldhash[16]);
+                               char nt_newpass[516], uchar nt_oldhash[16],
+                               char lm_newpass[516], uchar lm_oldhash[16]);
 void samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER *q_u, prs_struct *ps, int depth);
 void make_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER *r_u, uint32 status);
 void samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER *r_u, prs_struct *ps, int depth);
@@ -2210,7 +2210,7 @@ BOOL smb_password_check(char *password, unsigned char *part_passwd, unsigned cha
 BOOL smb_password_ok(struct smb_passwd *smb_pass, uchar chal[8],
                      uchar lm_pass[24], uchar nt_pass[24]);
 BOOL pass_check_smb(char *user, char *domain,
-               uchar *chal, char *lm_pwd, char *nt_pwd,
+               uchar *chal, uchar *lm_pwd, uchar *nt_pwd,
                struct passwd *pwd);
 BOOL password_ok(char *user, char *password, int pwlen, struct passwd *pwd);
 BOOL user_ok(char *user,int snum);
index e412bad2a7835e1983075be50341657938b73ed4..15025ceef31894b1dd84091d8740285034c2ab5a 100644 (file)
@@ -104,7 +104,7 @@ static BOOL rpc_read(struct cli_state *cli,
        DEBUG(5,("rpc_read: offset end: 0x%x.  data left to read:0x%x\n",
                  rdata->data->offset.end, data_to_read));
 
-       return rdata->data->data != NULL;
+       return True;
 }
 
 /****************************************************************************
@@ -229,7 +229,6 @@ static BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd,
                   prs_struct *rparam, prs_struct *rdata)
 {
        int len;
-       int alloc_hint = 0;
 
        uint16 setup[2]; /* only need 2 uint16 setup parameters */
        uint32 err;
@@ -303,7 +302,6 @@ static BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd,
        {
                RPC_HDR_RESP rhdr_resp;
                smb_io_rpc_hdr_resp("rpc_hdr_resp", &rhdr_resp, rdata, 0);
-               alloc_hint = rhdr_resp.alloc_hint;
        }
 
        DEBUG(5,("rpc_api_pipe: len left: %d smbtrans read: %d\n",
index fae96b561c75858fa8641cf4ee747d43365ac666..294317acc2f79a111ef633a83853d26bb811a66a 100644 (file)
@@ -102,8 +102,8 @@ do a SAMR change user password command
 ****************************************************************************/
 BOOL do_samr_chgpasswd_user(struct cli_state *cli,
                char *srv_name, char *user_name,
-               char nt_newpass[516], char nt_oldhash[16],
-               char lm_newpass[516], char lm_oldhash[16])
+               char nt_newpass[516], uchar nt_oldhash[16],
+               char lm_newpass[516], uchar lm_oldhash[16])
 {
        prs_struct data;
        prs_struct rdata;
index 58f726b6e41af1cec5b8ab84d0b80e4a66307421..40041e67c579c2ae03c2b08c7e845aa73ae4efbf 100644 (file)
@@ -2682,7 +2682,7 @@ void samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD *pwd, prs_struct *ps, int de
 /*******************************************************************
 makes a SAMR_ENC_HASH structure.
 ********************************************************************/
-void make_enc_hash(SAMR_ENC_HASH *hsh, char hash[16])
+void make_enc_hash(SAMR_ENC_HASH *hsh, uchar hash[16])
 {
        if (hsh == NULL) return;
 
@@ -2711,8 +2711,8 @@ makes a SAMR_R_UNKNOWN_38 structure.
 ********************************************************************/
 void make_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u,
                                char *dest_host, char *user_name,
-                               char nt_newpass[516], char nt_oldhash[16],
-                               char lm_newpass[516], char lm_oldhash[16])
+                               char nt_newpass[516], uchar nt_oldhash[16],
+                               char lm_newpass[516], uchar lm_oldhash[16])
 {
        int len_dest_host = strlen(dest_host);
        int len_user_name = strlen(user_name);
index fde654bcc4fbc6fc96a597af9c72eb08b7234a66..3269ab4e6197c870ef2754a63775e49cce4366c1 100644 (file)
@@ -339,7 +339,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p)
        become_root(True);
        p->ntlmssp_validated = pass_check_smb(p->user_name, p->domain,
                              (uchar*)p->ntlmssp_chal.challenge,
-                             (char*)lm_owf, (char*)nt_owf, NULL);
+                             lm_owf, nt_owf, NULL);
        smb_pass = getsmbpwnam(p->user_name);
        unbecome_root(True);
 
index d5ca2b2b1d97ea5cd4bca02f3598640c5d859fab..8e65e9a7b56eeb3b617c4b0a3a5cdd4cff1cc8c5 100644 (file)
@@ -51,11 +51,13 @@ void cmd_netlogon_login_test(struct client_info *info)
        char *nt_password;
        unsigned char trust_passwd[16];
 
+#if 0
        /* machine account passwords */
        pstring new_mach_pwd;
 
        /* initialisation */
        new_mach_pwd[0] = 0;
+#endif
 
        if (!next_token(NULL, nt_user_name, NULL, sizeof(nt_user_name)))
        {
index fa4c631899e711984829038ec13388c013874f01..f14c84d6b9b2da5c4bfaa46507dd8a4fcc8df57f 100644 (file)
@@ -99,8 +99,8 @@ void cmd_sam_ntchange_pwd(struct client_info *info)
        /* establish a connection. */
        res = res ? do_samr_chgpasswd_user(smb_cli,
                                           srv_name, smb_cli->user_name,
-                                          nt_newpass, (char*)nt_hshhash,
-                                          lm_newpass, (char*)lm_hshhash) : False;
+                                          nt_newpass, nt_hshhash,
+                                          lm_newpass, lm_hshhash) : False;
        /* close the session */
        cli_nt_session_close(smb_cli);
 
index 91062268f9cbb768fb6c952b67bd2e4604767c73..59022c80a83119af189206b989b705b718f6161d 100644 (file)
@@ -455,9 +455,9 @@ BOOL chgpasswd(char *name,char *oldpass,char *newpass, BOOL as_root)
 BOOL check_lanman_password(char *user, uchar *pass1, 
                            uchar *pass2, struct smb_passwd **psmbpw)
 {
+  static uchar null_pw[16];
   uchar unenc_new_pw[16];
   uchar unenc_old_pw[16];
-  uchar null_pw[16];
   struct smb_passwd *smbpw;
 
   *psmbpw = NULL;
@@ -482,7 +482,7 @@ BOOL check_lanman_password(char *user, uchar *pass1,
   {
     uchar no_pw[14];
     memset(no_pw, '\0', 14);
-    E_P16((uchar *)no_pw, (uchar *)null_pw);
+    E_P16(no_pw, null_pw);
     smbpw->smb_passwd = null_pw;
   } else if (smbpw->smb_passwd == NULL) {
     DEBUG(0,("check_lanman_password: no lanman password !\n"));
@@ -514,8 +514,8 @@ BOOL check_lanman_password(char *user, uchar *pass1,
 
 BOOL change_lanman_password(struct smb_passwd *smbpw, uchar *pass1, uchar *pass2)
 {
+  static uchar null_pw[16];
   uchar unenc_new_pw[16];
-  uchar null_pw[16];
   BOOL ret;
 
   if (smbpw == NULL)
@@ -534,7 +534,7 @@ BOOL change_lanman_password(struct smb_passwd *smbpw, uchar *pass1, uchar *pass2
   {
     uchar no_pw[14];
     memset(no_pw, '\0', 14);
-    E_P16((uchar *)no_pw, (uchar *)null_pw);
+    E_P16(no_pw, null_pw);
     smbpw->smb_passwd = null_pw;
   } else if (smbpw->smb_passwd == NULL) {
     DEBUG(0,("change_lanman_password: no lanman password !\n"));
@@ -605,15 +605,16 @@ BOOL check_oem_password(char *user,
                         struct smb_passwd **psmbpw, char *new_passwd,
                         int new_passwd_size)
 {
+       static uchar null_pw[16];
+       static uchar null_ntpw[16];
        struct smb_passwd *smbpw = NULL;
        int new_pw_len;
        uchar new_ntp16[16];
        uchar unenc_old_ntpw[16];
        uchar new_p16[16];
        uchar unenc_old_pw[16];
-       uchar null_pw[16];
-       uchar null_ntpw[16];
        char no_pw[2];
+
        BOOL nt_pass_set = (ntdata != NULL && nthash != NULL);
 
        become_root(False);
index 4e4eeb40ca0f5039a87de57f01822f1231706417..112a79b5ca852db7ab9ce55c6b443882af8e1461 100644 (file)
@@ -1732,7 +1732,7 @@ static BOOL api_SamOEMChangePassword(connection_struct *conn,uint16 vuid, char *
    */
   (void)Get_Pwnam( user, True);
 
-  if (pass_oem_change(user, (uchar*) data, (uchar*)(&data[516]), NULL, NULL))
+  if (pass_oem_change(user, (uchar*) data, (uchar *)&data[516], NULL, NULL))
   {
     SSVAL(*rparam,0,NERR_Success);
   }
index eac8c9cd65dd6b1ac558f5761d8b49b3932f9b6a..95560df66b490cfb89d9483a201f6af24f0ee6e1 100644 (file)
@@ -458,8 +458,9 @@ check if a username/password is OK assuming the password is a 24 byte
 SMB hash
 return True if the password is correct, False otherwise
 ****************************************************************************/
+
 BOOL pass_check_smb(char *user, char *domain,
-               uchar *chal, char *lm_pwd, char *nt_pwd,
+               uchar *chal, uchar *lm_pwd, uchar *nt_pwd,
                struct passwd *pwd)
 {
        struct passwd *pass;
@@ -513,7 +514,7 @@ BOOL pass_check_smb(char *user, char *domain,
                return(True);
        }
 
-       if (smb_password_ok(smb_pass, chal, (uchar *)lm_pwd, (uchar *)nt_pwd))
+       if (smb_password_ok(smb_pass, chal, lm_pwd, nt_pwd))
        {
                return(True);
        }
@@ -541,7 +542,7 @@ BOOL password_ok(char *user, char *password, int pwlen, struct passwd *pwd)
                }
 
                return pass_check_smb(user, global_myworkgroup,
-                                     challenge, password, password, pwd);
+                                     challenge, (uchar *)password, (uchar *)password, pwd);
        } 
 
        return pass_check(user, password, pwlen, pwd, 
index 35bd10fb13d0d37afcb70468eb58b1cff2945ca2..5b057410cad628b8b298463892e8a26ac388f6d9 100644 (file)
@@ -1500,15 +1500,37 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
     files_struct *fsp = file_fsp(params,0);
     info_level = SVAL(params,2);    
 
-    CHECK_FSP(fsp,conn);
-    CHECK_ERROR(fsp);
+    if(fsp && fsp->open && fsp->is_directory) {
+      /*
+       * This is actually a SETFILEINFO on a directory
+       * handle (returned from an NT SMB). NT5.0 seems
+       * to do this call. JRA.
+       */
+      fname = fsp->fsp_name;
+      unix_convert(fname,conn,0,&bad_path,&st);
+      if (!check_name(fname,conn) || (!VALID_STAT(st) && dos_stat(fname,&st))) {
+        DEBUG(3,("fileinfo of %s failed (%s)\n",fname,strerror(errno)));
+        if((errno == ENOENT) && bad_path)
+        {
+          unix_ERR_class = ERRDOS;
+          unix_ERR_code = ERRbadpath;
+        }
+        return(UNIXERROR(ERRDOS,ERRbadpath));
+      }
+    } else {
+      /*
+       * Original code - this is an open file.
+       */
+      CHECK_FSP(fsp,conn);
+      CHECK_ERROR(fsp);
 
-    fname = fsp->fsp_name;
-    fd = fsp->fd_ptr->fd;
+      fname = fsp->fsp_name;
+      fd = fsp->fd_ptr->fd;
 
-    if(sys_fstat(fd,&st)!=0) {
-      DEBUG(3,("fstat of %s failed (%s)\n", fname, strerror(errno)));
-      return(UNIXERROR(ERRDOS,ERRbadpath));
+      if (sys_fstat(fd,&st) != 0) {
+        DEBUG(3,("fstat of fnum %d failed (%s)\n",fsp->fnum, strerror(errno)));
+        return(UNIXERROR(ERRDOS,ERRbadfid));
+      }
     }
   } else {
     /* set path info */