summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pool <mbp@samba.org>2002-01-16 02:42:07 +0000
committerMartin Pool <mbp@samba.org>2002-01-16 02:42:07 +0000
commitfed604bfa368a2bb1fed414e368d491e4c7d7005 (patch)
tree06157b6c9fda86e3ec5ecd1448ab6534eb7ec19c
parent978f1ba98d91851a04facef76b9ea9adaf4add3e (diff)
downloadsamba-fed604bfa368a2bb1fed414e368d491e4c7d7005.tar.gz
samba-fed604bfa368a2bb1fed414e368d491e4c7d7005.tar.bz2
samba-fed604bfa368a2bb1fed414e368d491e4c7d7005.zip
Roll back PSTRING_SANCTIFY patch; just leave non-controversial type
and constness changes. (This used to be commit cee0ec72746122c962e6c5278a736266a7f2c424)
-rw-r--r--source3/include/pstring.h35
-rw-r--r--source3/include/safe_string.h9
-rw-r--r--source3/lib/util_str.c4
-rw-r--r--source3/param/loadparm.c2
-rw-r--r--source3/smbd/service.c39
5 files changed, 30 insertions, 59 deletions
diff --git a/source3/include/pstring.h b/source3/include/pstring.h
index 97ad5c9397..5f3f21cb1d 100644
--- a/source3/include/pstring.h
+++ b/source3/include/pstring.h
@@ -28,44 +28,9 @@
#define PSTRING_LEN 1024
#define FSTRING_LEN 256
-#ifdef PSTRING_SANCTIFY
-
-/* If you define this, pstring and fstring become distinguished types,
- * so that it's harder to accidentally overflow them by for example
- * passing an fstring on the lhs of pstrcpy.
- *
- * To pass them to non-pstring-aware functions, use PSTR and check
- * that the function takes a const. They should almost never be
- * modified except by special calls. In those unusual cases, use
- * PSTR_MUTABLE.
- *
- * This is off by default so as not to produce too many warnings. As
- * the code is vetted it can become the default. */
-
-typedef union { char pstring_contents[PSTRING_LEN]; } pstring[1];
-typedef union { char fstring_contents[FSTRING_LEN]; } fstring[1];
-
-# define PSTR(p) ((const char *) ((p)->pstring_contents))
-# define FSTR(f) ((const char *) ((f)->fstring_contents))
-
-/* Please use the const functions instead if possible. */
-# define PSTR_MUTABLE(p) (((p)->pstring_contents))
-# define FSTR_MUTABLE(f) (((f)->fstring_contents))
-
-#else /* ndef PSTRING_SANCTIFY */
-
-/* Old interface. */
-
typedef char pstring[PSTRING_LEN];
typedef char fstring[FSTRING_LEN];
-#define PSTR(p) ((const char *) p)
-#define FSTR(f) ((const char *) f)
-#define PSTR_MUTABLE(p) (p)
-#define FSTR_MUTABLE(f) (f)
-
-#endif /* ndef PSTRING_SANCTIFY */
-
#define _PSTRING
#endif /* ndef _PSTRING */
diff --git a/source3/include/safe_string.h b/source3/include/safe_string.h
index c4f44c0a34..a086d7495c 100644
--- a/source3/include/safe_string.h
+++ b/source3/include/safe_string.h
@@ -1,6 +1,5 @@
/*
Unix SMB/Netbios implementation.
- Version 1.9.
Safe string handling routines.
Copyright (C) Andrew Tridgell 1994-1998
@@ -37,10 +36,10 @@
#endif /* sprintf */
#define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
-#define pstrcpy(d,s) safe_strcpy(PSTR_MUTABLE(d), (s),sizeof(pstring)-1)
-#define pstrcat(d,s) safe_strcat(PSTR_MUTABLE(d), (s),sizeof(pstring)-1)
-#define fstrcpy(d,s) safe_strcpy(FSTR_MUTABLE(d),(s),sizeof(fstring)-1)
-#define fstrcat(d,s) safe_strcat(FSTR_MUTABLE(d),(s),sizeof(fstring)-1)
+#define pstrcpy(d,s) safe_strcpy((d), (s),sizeof(pstring)-1)
+#define pstrcat(d,s) safe_strcat((d), (s),sizeof(pstring)-1)
+#define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
+#define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
#define wpstrcpy(d,s) safe_strcpy_w((d),(s),sizeof(wpstring))
#define wpstrcat(d,s) safe_strcat_w((d),(s),sizeof(wpstring))
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index b1d50ad911..dbfaf179a1 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -945,7 +945,7 @@ int pstr_sprintf(pstring s, const char *fmt, ...)
int ret;
va_start(ap, fmt);
- ret = vsnprintf(PSTR_MUTABLE(s), PSTRING_LEN, fmt, ap);
+ ret = vsnprintf(s, PSTRING_LEN, fmt, ap);
va_end(ap);
return ret;
}
@@ -958,7 +958,7 @@ int fstr_sprintf(fstring s, const char *fmt, ...)
int ret;
va_start(ap, fmt);
- ret = vsnprintf(FSTR_MUTABLE(s), FSTRING_LEN, fmt, ap);
+ ret = vsnprintf(s, FSTRING_LEN, fmt, ap);
va_end(ap);
return ret;
}
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 461fd8f05e..f6771b85d9 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -1885,7 +1885,7 @@ BOOL lp_add_home(const char *pszHomename, int iDefaultService, const char *pszHo
/***************************************************************************
add a new service, based on an old one.
***************************************************************************/
-int lp_add_service(char *pszService, int iDefaultService)
+int lp_add_service(const char *pszService, int iDefaultService)
{
return (add_a_service(ServicePtrs[iDefaultService], pszService));
}
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index 120868f24a..9b6f38f2ec 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -104,17 +104,19 @@ int add_home_service(const char *service, const char *homedir)
if ((usr_p = strchr_m(service,*lp_winbind_separator())) != NULL)
fstrcpy(new_service, usr_p+1);
- lp_add_home(new_service,iHomeService,homedir);
+ lp_add_home(new_service, iHomeService, homedir);
iService = lp_servicenumber(new_service);
return iService;
}
-/****************************************************************************
- Find a service entry. service is always in dos codepage.
-****************************************************************************/
-int find_service(char *service)
+/**
+ * Find a service entry. service is always in dos codepage.
+ *
+ * @param service is modified (to canonical form??)
+ **/
+int find_service(fstring service)
{
int iService;
@@ -158,7 +160,7 @@ int find_service(char *service)
{
DEBUG(3,("%s is a valid printer name\n", service));
DEBUG(3,("adding %s as a printer service\n", service));
- lp_add_printer(service,iPrinterService);
+ lp_add_printer(service, iPrinterService);
iService = lp_servicenumber(service);
if (iService < 0)
DEBUG(0,("failed to add %s as a printer service!\n", service));
@@ -192,8 +194,8 @@ int find_service(char *service)
iService = find_service(defservice);
if (iService >= 0)
{
- all_string_sub(service,"_","/",0);
- iService = lp_add_service(service,iService);
+ all_string_sub(service, "_","/",0);
+ iService = lp_add_service(service, iService);
}
}
}
@@ -201,7 +203,7 @@ int find_service(char *service)
if (iService >= 0)
if (!VALID_SNUM(iService))
{
- DEBUG(0,("Invalid snum %d for %s\n",iService,service));
+ DEBUG(0,("Invalid snum %d for %s\n",iService, service));
iService = -1;
}
@@ -216,7 +218,7 @@ int find_service(char *service)
do some basic sainity checks on the share.
This function modifies dev, ecode.
****************************************************************************/
-static NTSTATUS share_sanity_checks(int snum, char* service, char *dev)
+static NTSTATUS share_sanity_checks(int snum, char* service, pstring dev)
{
if (!lp_snum_ok(snum) ||
@@ -229,7 +231,7 @@ static NTSTATUS share_sanity_checks(int snum, char* service, char *dev)
if (strequal(service,"IPC$") || strequal(service,"ADMIN$"))
pstrcpy(dev,"IPC");
- if (*dev == '?' || !*dev) {
+ if (dev[0] == '?' || !dev[0]) {
if (lp_print_ok(snum)) {
pstrcpy(dev,"LPT1:");
} else {
@@ -318,10 +320,12 @@ static void set_admin_user(connection_struct *conn)
/****************************************************************************
Make a connection to a service.
+ *
+ * @param service (May be modified to canonical form???)
****************************************************************************/
connection_struct *make_connection(char *service, DATA_BLOB password,
- char *dev,uint16 vuid, NTSTATUS *status)
+ const char *dev, uint16 vuid, NTSTATUS *status)
{
int snum;
struct passwd *pass = NULL;
@@ -361,16 +365,19 @@ connection_struct *make_connection(char *service, DATA_BLOB password,
if (validated_username(vuid)) {
fstring unix_username;
fstrcpy(unix_username,validated_username(vuid));
- return(make_connection(unix_username,password,dev,vuid,status));
+ return make_connection(unix_username,
+ password,dev,vuid,status);
}
} else {
/* Security = share. Try with current_user_info.smb_name
* as the username. */
- if(*current_user_info.smb_name) {
+ if (* current_user_info.smb_name) {
fstring unix_username;
- fstrcpy(unix_username,current_user_info.smb_name);
+ fstrcpy(unix_username,
+ current_user_info.smb_name);
map_username(unix_username);
- return(make_connection(unix_username,password,dev,vuid,status));
+ return make_connection(unix_username,
+ password,dev,vuid,status);
}
}
}