diff options
author | Martin Pool <mbp@samba.org> | 2002-01-15 02:15:58 +0000 |
---|---|---|
committer | Martin Pool <mbp@samba.org> | 2002-01-15 02:15:58 +0000 |
commit | 5a403da4a735a8fb8d118a0a67f3a15127152e18 (patch) | |
tree | e6878d9c1ff981599d82efe0a04f607ebb30e88d /source/smbd | |
parent | 04e3082f7d45c1b304adff5a46106136cff0e09e (diff) | |
download | samba-5a403da4a735a8fb8d118a0a67f3a15127152e18.tar.gz samba-5a403da4a735a8fb8d118a0a67f3a15127152e18.tar.xz samba-5a403da4a735a8fb8d118a0a67f3a15127152e18.zip |
Convert to the new pstring interface. This diff is a pretty good
example of the scope of change the new pstrings would entail:
basically inserting PSTR() or FSTR() everywhere you need to coerce one
to a char*.
It's also a good example of the kind of bug we might catch: on about
line 540, we were doing a pstrcpy into an fstring, which might
overflow. It's not a problem in this particular case, but it is in
general.
Diffstat (limited to 'source/smbd')
-rw-r--r-- | source/smbd/server.c | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/source/smbd/server.c b/source/smbd/server.c index 330feece916..4f3a46bca17 100644 --- a/source/smbd/server.c +++ b/source/smbd/server.c @@ -1,8 +1,8 @@ /* Unix SMB/Netbios implementation. - Version 1.9. Main SMB server routines - Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) Martin Pool 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,6 +19,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#define PSTRING_SANCTIFY + #include "includes.h" extern fstring global_myworkgroup; @@ -117,7 +119,7 @@ static BOOL open_sockets_inetd(void) close_low_fds(); set_socket_options(smbd_server_fd(),"SO_KEEPALIVE"); - set_socket_options(smbd_server_fd(),user_socket_options); + set_socket_options(smbd_server_fd(), PSTR(user_socket_options)); return True; } @@ -183,7 +185,7 @@ max can be %d\n", /* ready to listen */ set_socket_options(s,"SO_KEEPALIVE"); - set_socket_options(s,user_socket_options); + set_socket_options(s,PSTR(user_socket_options)); if (listen(s, 5) == -1) { DEBUG(0,("listen: %s\n",strerror(errno))); @@ -205,7 +207,7 @@ max can be %d\n", /* ready to listen */ set_socket_options(s,"SO_KEEPALIVE"); - set_socket_options(s,user_socket_options); + set_socket_options(s,PSTR(user_socket_options)); if (listen(s, 5) == -1) { DEBUG(0,("open_sockets: listen: %s\n", @@ -299,7 +301,7 @@ max can be %d\n", am_parent = 0; set_socket_options(smbd_server_fd(),"SO_KEEPALIVE"); - set_socket_options(smbd_server_fd(),user_socket_options); + set_socket_options(smbd_server_fd(),PSTR(user_socket_options)); /* Reset global variables in util.c so that client substitutions will be @@ -356,8 +358,9 @@ BOOL reload_services(BOOL test) if (lp_loaded()) { pstring fname; pstrcpy(fname,lp_configfile()); - if (file_exist(fname,NULL) && !strcsequal(fname,dyn_CONFIGFILE)) { - pstrcpy(dyn_CONFIGFILE,fname); + if (file_exist(PSTR(fname), NULL) && + !strcsequal(PSTR(fname), PSTR(dyn_CONFIGFILE))) { + pstrcpy(dyn_CONFIGFILE, PSTR(fname)); test = False; } } @@ -369,7 +372,7 @@ BOOL reload_services(BOOL test) lp_killunused(conn_snum_used); - ret = lp_load(dyn_CONFIGFILE,False,False,True); + ret = lp_load(PSTR(dyn_CONFIGFILE), False, False, True); load_printers(); @@ -384,7 +387,7 @@ BOOL reload_services(BOOL test) { if (smbd_server_fd() != -1) { set_socket_options(smbd_server_fd(),"SO_KEEPALIVE"); - set_socket_options(smbd_server_fd(),user_socket_options); + set_socket_options(smbd_server_fd(), PSTR(user_socket_options)); } } @@ -425,13 +428,14 @@ static BOOL dump_core(void) { char *p; pstring dname; + pstrcpy(dname,lp_logfile()); - if ((p=strrchr_m(dname,'/'))) *p=0; + if ((p=strrchr_m(PSTR(dname),'/'))) *p=0; pstrcat(dname,"/corefiles"); - mkdir(dname,0700); - sys_chown(dname,getuid(),getgid()); - chmod(dname,0700); - if (chdir(dname)) return(False); + mkdir(PSTR(dname),0700); + sys_chown(PSTR(dname),getuid(),getgid()); + chmod(PSTR(dname),0700); + if (chdir(PSTR(dname))) return(False); umask(~(0700)); #ifdef HAVE_GETRLIMIT @@ -449,7 +453,7 @@ static BOOL dump_core(void) #endif - DEBUG(0,("Dumping core in %s\n",dname)); + DEBUG(0,("Dumping core in %s\n", PSTR(dname))); abort(); return(True); } @@ -534,15 +538,15 @@ static void init_structs(void ) * set from the config file. */ - if (!*global_myname) { + if (!*PSTR(global_myname)) { char *p; - fstrcpy( global_myname, myhostname() ); - p = strchr_m( global_myname, '.' ); + pstrcpy( global_myname, myhostname() ); + p = strchr_m(PSTR(global_myname), '.' ); if (p) *p = 0; } - strupper( global_myname ); + strupper(PSTR_MUTABLE(global_myname)); conn_init(); @@ -617,8 +621,8 @@ static void usage(char *pname) case 'l': specified_logfile = True; - slprintf(logfile, sizeof(logfile)-1, "%s/log.smbd", optarg); - lp_set_logfile(logfile); + pstr_sprintf(logfile, "%s/log.smbd", optarg); + lp_set_logfile(PSTR(logfile)); break; case 'a': @@ -680,12 +684,11 @@ static void usage(char *pname) append_log = True; if(!specified_logfile) { - slprintf(logfile, sizeof(logfile)-1, "%s/log.smbd", - dyn_LOGFILEBASE); - lp_set_logfile(logfile); + pstr_sprintf(logfile, "%s/log.smbd", PSTR(dyn_LOGFILEBASE)); + lp_set_logfile(PSTR(logfile)); } - pstrcpy(remote_machine, "smbd"); + fstrcpy(remote_machine, "smbd"); setup_logging(argv[0],interactive); |