]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix many syntax warnings in smb_lm
authorAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 24 Apr 2009 07:06:46 +0000 (01:06 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 24 Apr 2009 07:06:46 +0000 (01:06 -0600)
Now compiled with the same CFLAGS as the rest of Squid.
This is tested up to gcc 3.4 standards now. Some may still
be raised by later gcc versions.

 - fixes const correctness on several functions and globals
 - fixes .h wrapping on several files
 - adds prototype definitions for all functions
 - adds several missing includes
 - adds docs for some functions to auto-doc output

TODO:
 Not all code audited, only the bits shown broken right now.
 This helper contains a large amount of nasty duplicate code
 and re-implements several encryption algoritms that should
 probably be sourced from secure places.

18 files changed:
helpers/ntlm_auth/smb_lm/libntlmssp.c
helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c
helpers/ntlm_auth/smb_lm/smbval/md4.c
helpers/ntlm_auth/smb_lm/smbval/md4.h
helpers/ntlm_auth/smb_lm/smbval/rfcnb-common.h
helpers/ntlm_auth/smb_lm/smbval/rfcnb-error.h
helpers/ntlm_auth/smb_lm/smbval/rfcnb-io.c
helpers/ntlm_auth/smb_lm/smbval/rfcnb-io.h
helpers/ntlm_auth/smb_lm/smbval/rfcnb.h
helpers/ntlm_auth/smb_lm/smbval/session.c
helpers/ntlm_auth/smb_lm/smbval/smbdes.c
helpers/ntlm_auth/smb_lm/smbval/smbdes.h
helpers/ntlm_auth/smb_lm/smbval/smbencrypt.c
helpers/ntlm_auth/smb_lm/smbval/smbencrypt.h
helpers/ntlm_auth/smb_lm/smbval/smblib-priv.h
helpers/ntlm_auth/smb_lm/smbval/smblib-util.c
helpers/ntlm_auth/smb_lm/smbval/smblib.c
helpers/ntlm_auth/smb_lm/smbval/valid.c

index 537e5518173e67546d9f57e628554d11ebf15e54..6cdc16ed41b24bb53a92e06e721960fcfd133267 100644 (file)
@@ -42,7 +42,7 @@ SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle, char *server, cha
 
 /* this one is reallllly haackiish. We really should be using anything from smblib-priv.h
  */
-static char *SMB_Prots[] = {"PC NETWORK PROGRAM 1.0",
+static char const *SMB_Prots[] = {"PC NETWORK PROGRAM 1.0",
                             "MICROSOFT NETWORKS 1.03",
                             "MICROSOFT NETWORKS 3.0",
                             "DOS LANMAN1.0",
index 7c97d14395b7fc1de13764c951cf10dddff9460d..b06eadb8aeea1828ec6324010ca51ee4b1c8a6c9 100644 (file)
 
 /* these are part of rfcnb-priv.h and smblib-priv.h */
 extern int SMB_Get_Error_Msg(int msg, char *msgbuf, int len);
-extern int SMB_Get_Last_Error();
-extern int SMB_Get_Last_SMB_Err();
-extern int RFCNB_Get_Last_Error();
+extern int SMB_Get_Last_Error(void);
+extern int SMB_Get_Last_SMB_Err(void);
+extern int RFCNB_Get_Last_Error(void);
+
 
 #include <errno.h>
 
@@ -53,6 +54,14 @@ extern int RFCNB_Get_Last_Error();
 #include <assert.h>
 #endif
 
+/* local functions */
+void send_bh_or_ld(char const *bhmessage, ntlm_authenticate * failedauth, int authlen);
+void usage(void);
+void process_options(int argc, char *argv[]);
+const char * obtain_challenge(void);
+void manage_request(void);
+
+
 #ifdef DEBUG
 char error_messages_buffer[BUFFER_SIZE];
 #endif
@@ -101,7 +110,7 @@ lc(char *string)
 
 
 void
-send_bh_or_ld(char *bhmessage, ntlm_authenticate * failedauth, int authlen)
+send_bh_or_ld(char const *bhmessage, ntlm_authenticate * failedauth, int authlen)
 {
 #ifdef NTLM_FAIL_OPEN
     char *creds = NULL;
@@ -228,7 +237,8 @@ process_options(int argc, char *argv[])
     last_dc->next = controllers;       /* close the queue, now it's circular */
 }
 
-/* tries connecting to the domain controllers in the "controllers" ring,
+/**
+ * tries connecting to the domain controllers in the "controllers" ring,
  * with failover if the adequate option is specified.
  */
 const char *
index 53180450293939e31f425931e202482b32223438..8bcf494c6dab490351e2d88f75e6c91e656c1cfe 100644 (file)
@@ -26,6 +26,7 @@
  */
 #include <string.h>
 #include "std-defines.h"       /* for the types */
+#include "md4.h"
 
 static uint32 A, B, C, D;
 
index 91733de76123851bfde110a4ca22a38aed9693ff..f2ad7496542df45af4b0540c0b5c452f742236b3 100644 (file)
@@ -1 +1,6 @@
-void mdfour(unsigned char *out, unsigned char *in, int n);\r
+#ifndef __SMB_LM_SMBVAL_MD4_H
+#define __SMB_LM_SMBVAL_MD4_H
+
+extern void mdfour(unsigned char *out, unsigned char *in, int n);
+
+#endif /* __SMB_LM_SMBVAL_MD4_H */
index 84f5a3dfe8e179742ca207a59fc5b597755978e7..653fb698aa4e7e34c620ded2b3296477fd0a57ca 100644 (file)
@@ -23,6 +23,9 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#ifndef _SMB_LM_SMBVAL_RFCNB_COMMON_H
+#define _SMB_LM_SMBVAL_RFCNB_COMMON_H
+
 /* A data structure we need */
 
 typedef struct RFCNB_Pkt {
@@ -32,3 +35,5 @@ typedef struct RFCNB_Pkt {
     struct RFCNB_Pkt *next;
 
 } RFCNB_Pkt;
+
+#endif /* _SMB_LM_SMBVAL_RFCNB_COMMON_H */
index e03ca5d9921b1c4ee60571341a96527fac92772f..0cb89995c653a1b922fcf609a0b1a2cccbe7d64b 100644 (file)
@@ -48,7 +48,7 @@
 #define RFCNBE_Timeout       16        /* IO Timed out                          */
 
 /* Text strings for the error responses                                 */
-extern char *RFCNB_Error_Strings[];
+extern char const *RFCNB_Error_Strings[];
 /*
  * static char *RFCNB_Error_Strings[] = {
  *
index e51956e8f5dd64375bc18fd5714349d681c4e655..d9700067e831fd93b3214ab861b754526a4895f8 100644 (file)
 #include <sys/signal.h>
 #include <string.h>
 
-int RFCNB_Timeout = 0;         /* Timeout in seconds ... */
+/* local functions */
+void rfcnb_alarm(int sig);
+int RFCNB_Set_Timeout(int seconds);
+int RFCNB_Discard_Rest(struct RFCNB_Con *con, int len);
+
+/* local globals */
+
+int RFCNB_Timeout = 0;         /**< Timeout in seconds ... */
 
 void
 rfcnb_alarm(int sig)
 {
-
     fprintf(stderr, "IO Timed out ...\n");
-
 }
 
-/* Set timeout value and setup signal handling */
-
+/** Set timeout value and setup signal handling */
 int
 RFCNB_Set_Timeout(int seconds)
 {
@@ -79,9 +83,9 @@ RFCNB_Set_Timeout(int seconds)
 
 }
 
-/* Discard the rest of an incoming packet as we do not have space for it
- * in the buffer we allocated or were passed ...                         */
-
+/** Discard the rest of an incoming packet as we do not have space for it
+ * in the buffer we allocated or were passed ...
+ */
 int
 RFCNB_Discard_Rest(struct RFCNB_Con *con, int len)
 {
@@ -122,14 +126,13 @@ RFCNB_Discard_Rest(struct RFCNB_Con *con, int len)
 }
 
 
-/* Send an RFCNB packet to the connection.
+/** Send an RFCNB packet to the connection.
  *
  * We just send each of the blocks linked together ...
  *
  * If we can, try to send it as one iovec ...
  *
  */
-
 int
 RFCNB_Put_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len)
 {
@@ -212,14 +215,12 @@ RFCNB_Put_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len)
 
 }
 
-/* Read an RFCNB packet off the connection.
+/** Read an RFCNB packet off the connection.
  *
  * We read the first 4 bytes, that tells us the length, then read the
  * rest. We should implement a timeout, but we don't just yet
  *
  */
-
-
 int
 RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len)
 {
index 46180d003074079559117c43acf3d0874baf4487..06aa5f5f46f7e45d0b55b8ee99f73c64dac52c80 100644 (file)
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-int RFCNB_Put_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len);
+#ifndef _SMB_LM_SMBVAL_RFCNB_IO_H
+#define _SMB_LM_SMBVAL_RFCNB_IO_H
 
-int RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len);
+extern int RFCNB_Put_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len);
 
-void RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt);
+extern int RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len);
+
+extern void RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt);
+
+#endif /* _SMB_LM_SMBVAL_RFCNB_IO_H */
index fb8bc207d0b0447eaeb87d0dd2f7479e14cc7093..eff6d7a268fd261980a7a1c0afc8c4ec12473588 100644 (file)
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#ifndef SMB_LM_SMBVAL_RFCNB_H
+#define SMB_LM_SMBVAL_RFCNB_H
+
 /* Error responses */
 
 #include "rfcnb-error.h"
 #include "rfcnb-common.h"
 #include "smblib-priv.h"
+#include "rfcnb-priv.h"
 
 /* Defines we need */
 
 
 /* Definition of routines we define */
 
-void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address,
-                 int port);
+extern void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, int port);
+
+extern int RFCNB_Send(struct RFCNB_Con *Con_Handle, struct RFCNB_Pkt *Data, int Length);
 
-int RFCNB_Send(void *Con_Handle, struct RFCNB_Pkt *Data, int Length);
+extern int RFCNB_Recv(void *Con_Handle, struct RFCNB_Pkt *Data, int Length);
 
-int RFCNB_Recv(void *Con_Handle, struct RFCNB_Pkt *Data, int Length);
+extern int RFCNB_Hangup(struct RFCNB_Con *con_Handle);
 
-int RFCNB_Hangup(void *con_Handle);
+extern void *RFCNB_Listen(void);
 
-void *RFCNB_Listen();
+extern void RFCNB_Get_Error(char *buffer, int buf_len);
 
-void RFCNB_Get_Error(char *buffer, int buf_len);
+extern struct RFCNB_Pkt *RFCNB_Alloc_Pkt(int n);
 
-struct RFCNB_Pkt *RFCNB_Alloc_Pkt(int n);
+extern void RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt);
 
-void RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt);
+extern int RFCNB_Set_Sock_NoDelay(struct RFCNB_Con *con_Handle, BOOL yn);
 
-int RFCNB_Set_Sock_NoDelay(void *con_Handle, BOOL yn);
+#endif /* SMB_LM_SMBVAL_RFCNB_H */
index 14a940116574500d476727cd0c1dc956f975975a..65776a360270b7430a90640d54aee0e742655ed4 100644 (file)
@@ -35,10 +35,19 @@ int RFCNB_saved_errno = 0;
 #include "rfcnb-priv.h"
 #include "rfcnb-util.h"
 #include "rfcnb-io.h"
+#include "rfcnb.h"
+
+
+/* local functions */
+
+int RFCNB_Get_Last_Error(void);
+int RFCNB_Get_Last_Errno(void);
+void RFCNB_Get_Error_Msg(int code, char *msg_buf, int len);
+void RFCNB_Register_Print_Routine(void (*fn) ());
 
 /* global data structures */
 
-char *RFCNB_Error_Strings[] = {
+char const * RFCNB_Error_Strings[] = {
 
     "RFCNBE_OK: Routine completed successfully.",
     "RFCNBE_NoSpace: No space available for a malloc call.",
index 8b0ccdfb7f7c78064471d8426e1d15788091cf53..8e1931219f5f905ace1fc0e2d63462bfe557719c 100644 (file)
  * up with a different answer to the one above)
  */
 
+#include "smbdes.h"
+
+/* local functions */
+void cred_hash1(unsigned char *out, unsigned char *in, unsigned char *key);
+void cred_hash2(unsigned char *out, unsigned char *in, unsigned char *key);
 
 
 static int perm1[56] = {57, 49, 41, 33, 25, 17, 9,
index 5a431140dd32d68cefcd4bac5d6651f8baa2f622..057fc22101f59a975d63eeca1df8aa01bf0f0c8b 100644 (file)
@@ -1,2 +1,7 @@
-void E_P16(unsigned char *p14, unsigned char *p16);
-void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24);
+#ifndef __SMB_LM_SMBVAL_SMBDES_H
+#define __SMB_LM_SMBVAL_SMBDES_H
+
+extern void E_P16(unsigned char *p14, unsigned char *p16);
+extern void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24);
+
+#endif /* __SMB_LM_SMBVAL_SMBDES_H */
index c585cecb937594f291d61cdf2140d4570f1f193e..3bbf4a2f7a8998890c928d4e0869e5950ca7dd13 100644 (file)
 #include "smblib-priv.h"
 #include "md4.h"
 #include "smbdes.h"
+
 #define uchar unsigned char
 extern int DEBUGLEVEL;
 
 #include "byteorder.h"
+#include "smbencrypt.h"
 
+/* local functions */
 char *StrnCpy(char *dest, char *src, int n);
 void strupper(char *s);
+void E_md4hash(uchar * passwd, uchar * p16);
+void nt_lm_owf_gen(char *pwd, char *nt_p16, char *p16);
 
 /*
  * This implements the X/Open SMB password encryption
@@ -91,10 +96,9 @@ _my_mbstowcs(int16 * dst, uchar * src, int len)
     return i;
 }
 
-/*
+/**
  * Creates the MD4 Hash of the users password in NT UNICODE.
  */
-
 void
 E_md4hash(uchar * passwd, uchar * p16)
 {
@@ -115,7 +119,6 @@ E_md4hash(uchar * passwd, uchar * p16)
 }
 
 /* Does the NT MD4 hash then des encryption. */
-
 void
 SMBNTencrypt(uchar * passwd, uchar * c8, uchar * p24)
 {
@@ -127,8 +130,7 @@ SMBNTencrypt(uchar * passwd, uchar * c8, uchar * p24)
     E_P24(p21, c8, p24);
 }
 
-/* Does both the NT and LM owfs of a user's password */
-
+/** Does both the NT and LM owfs of a user's password */
 void
 nt_lm_owf_gen(char *pwd, char *nt_p16, char *p16)
 {
index bf3b13f2b539b369c49f48a2c5c7f77544c4382c..cee12f7e66fbd356ee0ed6132c483d66c1a0974d 100644 (file)
@@ -1,3 +1,9 @@
-void SMBencrypt(uchar * passwd, uchar * c8, uchar * p24);
-void SMBNTencrypt(uchar * passwd, uchar * c8, uchar * p24);
+#ifndef __SMB_LM_SMBVAL_SMBENCRYPT_H
+#define __SMB_LM_SMBVAL_SMBENCRYPT_H
+
+
+extern void SMBencrypt(uchar * passwd, uchar * c8, uchar * p24);
+extern void SMBNTencrypt(uchar * passwd, uchar * c8, uchar * p24);
+
+#endif /* __SMB_LM_SMBVAL_SMBENCRYPT_H */
 
index 93dce361c22ab25546cbc8ef0a241aa97a2ce092..0530de7362d33040797937fbff8b2f18026e7ff1 100644 (file)
@@ -500,7 +500,7 @@ typedef enum {
 /* We must make it possible for callers to specify these ... */
 
 #if 0
-extern char *SMB_Prots[];
+extern char const *SMB_Prots[];
 
 /*
  * static char *SMB_Prots[] = {"PC NETWORK PROGRAM 1.0",
@@ -637,19 +637,19 @@ extern int SMBlib_errno;
 extern int SMBlib_SMB_Error;   /* last Error             */
 #endif
 
-SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type con, SMB_Tree_Handle tree,
-                                char *path, char *password, char *dev);
+extern SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type con, SMB_Tree_Handle tree,
+                                char *path, char *password, char const *dev);
 
-int SMB_Init();
-void SMB_Get_My_Name(char *name, int len);
-int SMB_Negotiate(SMB_Handle_Type Con_Handle, char *Prots[]);
-int SMB_Discon(SMB_Handle_Type Con_Handle, BOOL KeepHandle);
+extern int SMB_Init(void);
+extern void SMB_Get_My_Name(char *name, int len);
+extern int SMB_Negotiate(SMB_Handle_Type Con_Handle, char const *Prots[]);
+extern int SMB_Discon(SMB_Handle_Type Con_Handle, BOOL KeepHandle);
 
-int SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName,
+extern int SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName,
                      char *PassWord, char *UserDomain, int precrypted);
 
-int SMB_Get_Error_Msg(int msg, char *msgbuf, int len);
+extern int SMB_Get_Error_Msg(int msg, char *msgbuf, int len);
 
-int SMB_Get_Last_Error();
+extern int SMB_Get_Last_Error(void);
 
 #endif /* __SMBLIB_PRIV_H__ */
index f74b27c3905f05d093a1b73a51adfc0cb142762d..07b7b6712b5bbfa180d95b2af198de9d6d32d9e7 100644 (file)
 
 #include "rfcnb.h"
 
+/* local functions */
+char * SMB_DOSTimToStr(int DOS_time);
+char * SMB_AtrToStr(int attribs, BOOL verbose);
+int SMB_Get_Tree_MBS(SMB_Tree_Handle tree);
+int SMB_Get_Max_Buf_Siz(SMB_Handle_Type Con_Handle);
+int SMB_Get_Protocol_IDX(SMB_Handle_Type Con_Handle);
+int SMB_Get_Protocol(SMB_Handle_Type Con_Handle);
+int SMB_Figure_Protocol(char const *dialects[], int prot_index);
+int SMB_TreeDisconnect(SMB_Tree_Handle Tree_Handle, BOOL discard);
+// int SMB_Get_Last_Error(void);
+int SMB_Get_Last_SMB_Err(void);
+
+
 /* global data structures */
 
 static int SMB_Types[] = {SMB_P_Core,
@@ -46,7 +59,7 @@ static int SMB_Types[] = {SMB_P_Core,
                           -1
                          };
 
-static char *SMB_Prots[] = {"PC NETWORK PROGRAM 1.0",
+static char const *SMB_Prots[] = {"PC NETWORK PROGRAM 1.0",
                             "MICROSOFT NETWORKS 1.03",
                             "MICROSOFT NETWORKS 3.0",
                             "DOS LANMAN1.0",
@@ -62,7 +75,7 @@ static char *SMB_Prots[] = {"PC NETWORK PROGRAM 1.0",
                            };
 
 /* Print out an SMB pkt in all its gory detail ... */
-
+#if 0 // DEAD CODE
 void
 SMB_Print_Pkt(FILE fd, RFCNB_Pkt * pkt, BOOL command, int Offset, int Len)
 {
@@ -79,6 +92,7 @@ SMB_Print_Pkt(FILE fd, RFCNB_Pkt * pkt, BOOL command, int Offset, int Len)
     /* etc                                                 */
 
 }
+#endif /* 0 */
 
 /* Convert a DOS Date_Time to a local host type date time for printing */
 
@@ -105,10 +119,11 @@ SMB_DOSTimToStr(int DOS_time)
 
 }
 
-/* Convert an attribute byte/word etc to a string ... We return a pointer
+/**
+ * Convert an attribute byte/word etc to a string ... We return a pointer
  * to a static string which we guarantee is long enough. If verbose is
- * true, we print out long form of strings ...                            */
-
+ * true, we print out long form of strings ...
+ */
 char *
 SMB_AtrToStr(int attribs, BOOL verbose)
 {
@@ -138,8 +153,7 @@ SMB_AtrToStr(int attribs, BOOL verbose)
 
 }
 
-/* Pick up the Max Buffer Size from the Tree Structure ... */
-
+/** Pick up the Max Buffer Size from the Tree Structure ... */
 int
 SMB_Get_Tree_MBS(SMB_Tree_Handle tree)
 {
@@ -150,8 +164,7 @@ SMB_Get_Tree_MBS(SMB_Tree_Handle tree)
     }
 }
 
-/* Pick up the Max buffer size */
-
+/** Pick up the Max buffer size */
 int
 SMB_Get_Max_Buf_Siz(SMB_Handle_Type Con_Handle)
 {
@@ -162,8 +175,8 @@ SMB_Get_Max_Buf_Siz(SMB_Handle_Type Con_Handle)
     }
 
 }
-/* Pickup the protocol index from the connection structure                 */
 
+/* Pickup the protocol index from the connection structure                 */
 int
 SMB_Get_Protocol_IDX(SMB_Handle_Type Con_Handle)
 {
@@ -175,8 +188,7 @@ SMB_Get_Protocol_IDX(SMB_Handle_Type Con_Handle)
 
 }
 
-/* Pick up the protocol from the connection structure                       */
-
+/** Pick up the protocol from the connection structure                       */
 int
 SMB_Get_Protocol(SMB_Handle_Type Con_Handle)
 {
@@ -188,12 +200,13 @@ SMB_Get_Protocol(SMB_Handle_Type Con_Handle)
 
 }
 
-/* Figure out what protocol was accepted, given the list of dialect strings */
-/* We offered, and the index back from the server. We allow for a user      */
-/* supplied list, and assume that it is a subset of our list                */
-
+/**
+ * Figure out what protocol was accepted, given the list of dialect strings
+ * We offered, and the index back from the server. We allow for a user
+ * supplied list, and assume that it is a subset of our list
+ */
 int
-SMB_Figure_Protocol(char *dialects[], int prot_index)
+SMB_Figure_Protocol(char const *dialects[], int prot_index)
 {
     int i;
 
@@ -226,7 +239,7 @@ SMB_Figure_Protocol(char *dialects[], int prot_index)
 /* none acceptible, and our return value is 0 if ok, <0 if problems       */
 
 int
-SMB_Negotiate(SMB_Handle_Type Con_Handle, char *Prots[])
+SMB_Negotiate(SMB_Handle_Type Con_Handle, char const *Prots[])
 {
     struct RFCNB_Pkt *pkt;
     int prots_len, i, pkt_len, prot, alloc_len;
@@ -237,9 +250,7 @@ SMB_Negotiate(SMB_Handle_Type Con_Handle, char *Prots[])
     prots_len = 0;
 
     for (i = 0; Prots[i] != NULL; i++) {
-
         prots_len = prots_len + strlen(Prots[i]) + 2;  /* Account for null etc */
-
     }
 
     /* The -1 accounts for the one byte smb_buf we have because some systems */
@@ -251,25 +262,19 @@ SMB_Negotiate(SMB_Handle_Type Con_Handle, char *Prots[])
     /* Which is a problem, because the encryption key len eec may be long   */
 
     if (pkt_len < (SMB_hdr_wct_offset + (19 * 2) + 40)) {
-
         alloc_len = SMB_hdr_wct_offset + (19 * 2) + 40;
-
     } else {
-
         alloc_len = pkt_len;
-
     }
 
     pkt = (struct RFCNB_Pkt *) RFCNB_Alloc_Pkt(alloc_len);
 
     if (pkt == NULL) {
-
         SMBlib_errno = SMBlibE_NoSpace;
         return (SMBlibE_BAD);
-
     }
-    /* Now plug in the bits we need */
 
+    /* Now plug in the bits we need */
     memset(SMB_Hdr(pkt), 0, SMB_negp_len);
     SIVAL(SMB_Hdr(pkt), SMB_hdr_idf_offset, SMB_DEF_IDF);      /* Plunk in IDF */
     *(SMB_Hdr(pkt) + SMB_hdr_com_offset) = SMBnegprot;
@@ -278,7 +283,6 @@ SMB_Negotiate(SMB_Handle_Type Con_Handle, char *Prots[])
     SSVAL(SMB_Hdr(pkt), SMB_hdr_mid_offset, Con_Handle->mid);
     SSVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset, Con_Handle->uid);
     *(SMB_Hdr(pkt) + SMB_hdr_wct_offset) = 0;
-
     SSVAL(SMB_Hdr(pkt), SMB_negp_bcc_offset, prots_len);
 
     /* Now copy the prot strings in with the right stuff */
@@ -286,82 +290,65 @@ SMB_Negotiate(SMB_Handle_Type Con_Handle, char *Prots[])
     p = (char *) (SMB_Hdr(pkt) + SMB_negp_buf_offset);
 
     for (i = 0; Prots[i] != NULL; i++) {
-
         *p = SMBdialectID;
         strcpy(p + 1, Prots[i]);
         p = p + strlen(Prots[i]) + 2;  /* Adjust len of p for null plus dialectID */
-
     }
 
     /* Now send the packet and sit back ... */
-
     if (RFCNB_Send(Con_Handle->Trans_Connect, pkt, pkt_len) < 0) {
-
-
 #ifdef DEBUG
         fprintf(stderr, "Error sending negotiate protocol\n");
 #endif
-
         RFCNB_Free_Pkt(pkt);
         SMBlib_errno = -SMBlibE_SendFailed;    /* Failed, check lower layer errno */
         return (SMBlibE_BAD);
-
     }
-    /* Now get the response ... */
 
+    /* Now get the response ... */
     if (RFCNB_Recv(Con_Handle->Trans_Connect, pkt, alloc_len) < 0) {
-
 #ifdef DEBUG
         fprintf(stderr, "Error receiving response to negotiate\n");
 #endif
-
         RFCNB_Free_Pkt(pkt);
         SMBlib_errno = -SMBlibE_RecvFailed;    /* Failed, check lower layer errno */
         return (SMBlibE_BAD);
-
     }
-    if (CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset) != SMBC_SUCCESS) {     /* Process error */
 
+    if (CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset) != SMBC_SUCCESS) {     /* Process error */
 #ifdef DEBUG
         fprintf(stderr, "SMB_Negotiate failed with errorclass = %i, Error Code = %i\n",
                 CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset),
                 SVAL(SMB_Hdr(pkt), SMB_hdr_err_offset));
 #endif
-
         SMBlib_SMB_Error = IVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset);
         RFCNB_Free_Pkt(pkt);
         SMBlib_errno = SMBlibE_Remote;
         return (SMBlibE_BAD);
-
     }
-    if (SVAL(SMB_Hdr(pkt), SMB_negrCP_idx_offset) == 0xFFFF) {
 
+    if (SVAL(SMB_Hdr(pkt), SMB_negrCP_idx_offset) == 0xFFFF) {
 #ifdef DEBUG
         fprintf(stderr, "None of our protocols was accepted ... ");
 #endif
-
         RFCNB_Free_Pkt(pkt);
         SMBlib_errno = SMBlibE_NegNoProt;
         return (SMBlibE_BAD);
-
     }
+
     /* Now, unpack the info from the response, if any and evaluate the proto */
     /* selected. We must make sure it is one we like ...                     */
-
     Con_Handle->prot_IDX = prot = SVAL(SMB_Hdr(pkt), SMB_negrCP_idx_offset);
     Con_Handle->protocol = SMB_Figure_Protocol(Prots, prot);
 
     if (Con_Handle->protocol == SMB_P_Unknown) {       /* No good ... */
-
         RFCNB_Free_Pkt(pkt);
         SMBlib_errno = SMBlibE_ProtUnknown;
         return (SMBlibE_BAD);
-
     }
     switch (CVAL(SMB_Hdr(pkt), SMB_hdr_wct_offset)) {
 
     case 0x01:                 /* No more info ... */
-
         break;
 
     case 13:                   /* Up to and including LanMan 2.1 */
@@ -385,7 +372,6 @@ SMB_Negotiate(SMB_Handle_Type Con_Handle, char *Prots[])
         p = (SMB_Hdr(pkt) + SMB_negrLM_buf_offset + Con_Handle->Encrypt_Key_Len);
 
         strncpy(p, Con_Handle->Svr_PDom, sizeof(Con_Handle->Svr_PDom) - 1);
-
         break;
 
     case 17:                   /* NT LM 0.12 and LN LM 1.0 */
@@ -459,7 +445,7 @@ SMB_TreeConnect(SMB_Handle_Type Con_Handle,
                 SMB_Tree_Handle Tree_Handle,
                 char *path,
                 char *password,
-                char *device)
+                char const *device)
 {
     struct RFCNB_Pkt *pkt;
     int param_len, pkt_len;
@@ -730,9 +716,9 @@ SMB_Get_Last_Error()
 
 }
 
-/* Pick up the last error returned in an SMB packet          */
-/* We will need macros to extract error class and error code */
-
+/** Pick up the last error returned in an SMB packet
+ * We will need macros to extract error class and error code
+ */
 int
 SMB_Get_Last_SMB_Err()
 {
@@ -745,7 +731,7 @@ SMB_Get_Last_SMB_Err()
 
 /* Keep this table in sync with the message codes in smblib-common.h */
 
-static char *SMBlib_Error_Messages[] = {
+static char const *SMBlib_Error_Messages[] = {
 
     "Request completed sucessfully.",
     "Server returned a non-zero SMB Error Class and Code.",
index 3c8073751bc13bb2cb53135465eb6a55b95a9859..36edea86037ffef33dcb1b677b260e9642c3e454 100644 (file)
@@ -40,6 +40,14 @@ int SMBlib_SMB_Error;
 
 #include <signal.h>
 
+/* local functions */
+int SMB_Term(void);
+SMB_Handle_Type SMB_Create_Con_Handle(void);
+int SMBlib_Set_Sock_NoDelay(SMB_Handle_Type Con_Handle, BOOL yn);
+SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle, char *server, char *NTdomain);
+SMB_Handle_Type SMB_Connect(SMB_Handle_Type Con_Handle, SMB_Tree_Handle * tree, char *service, char *username, char *password);
+
+
 /* #define DEBUG */
 
 SMB_State_Types SMBlib_State;
@@ -79,38 +87,28 @@ SMB_Term()
 
 }
 
-/* SMB_Create: Create a connection structure and return for later use */
-/* We have other helper routines to set variables                     */
-
+/**
+ * SMB_Create: Create a connection structure and return for later use 
+ * We have other helper routines to set variables
+ */
 SMB_Handle_Type
 SMB_Create_Con_Handle()
 {
-
     SMBlib_errno = SMBlibE_NotImpl;
     return (NULL);
-
 }
 
 int
 SMBlib_Set_Sock_NoDelay(SMB_Handle_Type Con_Handle, BOOL yn)
 {
-
-
     if (RFCNB_Set_Sock_NoDelay(Con_Handle->Trans_Connect, yn) < 0) {
-
-#ifdef DEBUG
-#endif
-
         fprintf(stderr, "Setting no-delay on TCP socket failed ...\n");
-
     }
     return (0);
-
 }
 
 /* SMB_Connect_Server: Connect to a server, but don't negotiate protocol */
 /* or anything else ...                                                  */
-
 SMB_Handle_Type
 SMB_Connect_Server(SMB_Handle_Type Con_Handle,
                    char *server, char *NTdomain)
@@ -210,7 +208,7 @@ SMB_Connect_Server(SMB_Handle_Type Con_Handle,
 /* If Con_Handle == NULL then create a handle and connect, otherwise  */
 /* use the handle passed                                              */
 
-char *SMB_Prots_Restrict[] = {"PC NETWORK PROGRAM 1.0",
+char const *SMB_Prots_Restrict[] = {"PC NETWORK PROGRAM 1.0",
                               NULL
                              };
 
@@ -303,22 +301,18 @@ SMB_Connect(SMB_Handle_Type Con_Handle,
         return NULL;
 
     }
-    /* Now, negotiate the protocol */
 
+    /* Now, negotiate the protocol */
     if (SMB_Negotiate(con, SMB_Prots_Restrict) < 0) {
 
         /* Hmmm what should we do here ... We have a connection, but could not
          * negotiate ...                                                      */
-
         return NULL;
-
     }
-    /* Now connect to the service ... */
 
+    /* Now connect to the service ... */
     if ((*tree = SMB_TreeConnect(con, NULL, service, password, "A:")) == NULL) {
-
         return NULL;
-
     }
     return (con);
 
index 62a608c9a6b6076a29114e0589ac50c274663dbf..f481decbc20fa68ea2165dc12139a334ba508a95 100644 (file)
@@ -22,13 +22,13 @@ int
 Valid_User(char *username, char *password, char *server, char *backup, char *domain)
 {
     int pass_is_precrypted_p = 0;
-    char *SMB_Prots[] = {
+    char const *SMB_Prots[] = {
         /*              "PC NETWORK PROGRAM 1.0", */
         /*              "MICROSOFT NETWORKS 1.03", */
         /*              "MICROSOFT NETWORKS 3.0", */
-        (char*)"LANMAN1.0",
-        (char*)"LM1.2X002",
-        (char*)"Samba",
+        "LANMAN1.0",
+        "LM1.2X002",
+        "Samba",
         /*              "NT LM 0.12", */
         /*              "NT LANMAN 1.0", */
         NULL
@@ -63,13 +63,13 @@ Valid_User(char *username, char *password, char *server, char *backup, char *dom
 void *
 NTLM_Connect(char *server, char *backup, char *domain, char *nonce)
 {
-    char *SMB_Prots[] = {
+    char const *SMB_Prots[] = {
         /*              "PC NETWORK PROGRAM 1.0", */
         /*              "MICROSOFT NETWORKS 1.03", */
         /*              "MICROSOFT NETWORKS 3.0", */
-        (char*)"LANMAN1.0",
-        (char*)"LM1.2X002",
-        (char*)"Samba",
+        "LANMAN1.0",
+        "LM1.2X002",
+        "Samba",
         /*              "NT LM 0.12", */
         /*              "NT LANMAN 1.0", */
         NULL