From b9342eaaa6bf61f559e4173d7ea58acc1a0a9705 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 3 Dec 2007 15:19:22 -0800 Subject: Remove unused wpstring and macros. Stop using pstrcpy in smbd/*.c Jeremy. (This used to be commit e72bce5b62fb0a9d0ff4a3d76490219994f303cf) --- source3/include/includes.h | 23 ---------------- source3/include/safe_string.h | 31 ---------------------- source3/printing/nt_printing.c | 2 +- source3/smbd/lanman.c | 60 ++++++++++++++++++++++++------------------ 4 files changed, 35 insertions(+), 81 deletions(-) (limited to 'source3') diff --git a/source3/include/includes.h b/source3/include/includes.h index 5192c37901..9079c3aa82 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -699,29 +699,6 @@ struct timespec { #include "ctdbd_conn.h" #include "talloc_stack.h" -/* - * Type for wide character dirent structure. - * Only d_name is defined by POSIX. - */ - -typedef struct smb_wdirent { - wpstring d_name; -} SMB_STRUCT_WDIRENT; - -/* - * Type for wide character passwd structure. - */ - -typedef struct smb_wpasswd { - wfstring pw_name; - char *pw_passwd; - uid_t pw_uid; - gid_t pw_gid; - wpstring pw_gecos; - wpstring pw_dir; - wpstring pw_shell; -} SMB_STRUCT_WPASSWD; - /* used in net.c */ struct functable { const char *funcname; diff --git a/source3/include/safe_string.h b/source3/include/safe_string.h index 7a60ad695e..53ee7d312e 100644 --- a/source3/include/safe_string.h +++ b/source3/include/safe_string.h @@ -86,26 +86,6 @@ size_t __unsafe_string_function_usage_here_char__(void); #define CHECK_STRING_SIZE(d, len) (sizeof(d) != (len) && sizeof(d) != sizeof(char *)) -#define fstrterminate(d) (CHECK_STRING_SIZE(d, sizeof(fstring)) \ - ? __unsafe_string_function_usage_here_char__() \ - : (((d)[sizeof(fstring)-1]) = '\0')) -#define pstrterminate(d) (CHECK_STRING_SIZE(d, sizeof(pstring)) \ - ? __unsafe_string_function_usage_here_char__() \ - : (((d)[sizeof(pstring)-1]) = '\0')) - -#define wpstrcpy(d,s) ((sizeof(d) != sizeof(wpstring) && sizeof(d) != sizeof(smb_ucs2_t *)) \ - ? __unsafe_string_function_usage_here__() \ - : safe_strcpy_w((d),(s),sizeof(wpstring))) -#define wpstrcat(d,s) ((sizeof(d) != sizeof(wpstring) && sizeof(d) != sizeof(smb_ucs2_t *)) \ - ? __unsafe_string_function_usage_here__() \ - : safe_strcat_w((d),(s),sizeof(wpstring))) -#define wfstrcpy(d,s) ((sizeof(d) != sizeof(wfstring) && sizeof(d) != sizeof(smb_ucs2_t *)) \ - ? __unsafe_string_function_usage_here__() \ - : safe_strcpy_w((d),(s),sizeof(wfstring))) -#define wfstrcat(d,s) ((sizeof(d) != sizeof(wfstring) && sizeof(d) != sizeof(smb_ucs2_t *)) \ - ? __unsafe_string_function_usage_here__() \ - : safe_strcat_w((d),(s),sizeof(wfstring))) - #define push_pstring_base(dest, src, pstring_base) \ (CHECK_STRING_SIZE(pstring_base, sizeof(pstring)) \ ? __unsafe_string_function_usage_here_size_t__() \ @@ -113,14 +93,6 @@ size_t __unsafe_string_function_usage_here_char__(void); #else /* HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS */ -#define fstrterminate(d) (((d)[sizeof(fstring)-1]) = '\0') -#define pstrterminate(d) (((d)[sizeof(pstring)-1]) = '\0') - -#define wpstrcpy(d,s) safe_strcpy_w((d),(s),sizeof(wpstring)) -#define wpstrcat(d,s) safe_strcat_w((d),(s),sizeof(wpstring)) -#define wfstrcpy(d,s) safe_strcpy_w((d),(s),sizeof(wfstring)) -#define wfstrcat(d,s) safe_strcat_w((d),(s),sizeof(wfstring)) - #define push_pstring_base(dest, src, pstring_base) \ push_ascii(dest, src, sizeof(pstring)-PTR_DIFF(dest,pstring_base)-1, STR_TERMINATE) @@ -143,9 +115,6 @@ size_t __unsafe_string_function_usage_here_char__(void); /* the addition of the DEVELOPER checks in safe_strcpy means we must * update a lot of code. To make this a little easier here are some * functions that provide the lengths with less pain */ -#define pstrcpy_base(dest, src, pstring_base) \ - safe_strcpy(dest, src, sizeof(pstring)-PTR_DIFF(dest,pstring_base)-1) - /* Inside the _fn variants of these is a call to clobber_region(), - * which might destroy the stack on a buggy function. We help the diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index afa4bc2fd5..55dd63be78 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -3956,7 +3956,7 @@ static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 *info, const char DEBUG(10,("get_a_printer_2_default: driver name set to [%s]\n", info->drivername)); - pstrcpy(info->comment, ""); + strlcpy(info->comment, "", sizeof(info->comment)); fstrcpy(info->printprocessor, "winprint"); fstrcpy(info->datatype, "RAW"); diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index 17ab891c64..b194fc6231 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -2130,6 +2130,7 @@ static bool api_NetUserGetGroups(connection_struct *conn,uint16 vuid, NTSTATUS result; DOM_SID user_sid; enum lsa_SidType type; + char *endp = NULL; TALLOC_CTX *mem_ctx; if (!str1 || !str2 || !UserName || !p) { @@ -2168,6 +2169,7 @@ static bool api_NetUserGetGroups(connection_struct *conn,uint16 vuid, SSVAL(*rparam,2,0); /* converter word */ p = *rdata; + endp = *rdata + *rdata_len; mem_ctx = talloc_new(NULL); if (mem_ctx == NULL) { @@ -2181,7 +2183,7 @@ static bool api_NetUserGetGroups(connection_struct *conn,uint16 vuid, return False; } - /* Lookup the user information; This should only be one of + /* Lookup the user information; This should only be one of our accounts (not remote domains) */ become_root(); /* ROOT BLOCK */ @@ -2218,12 +2220,11 @@ static bool api_NetUserGetGroups(connection_struct *conn,uint16 vuid, } for (i=0; i return parameter number of entries * h -> return parameter total number of users */ - + resume_context = get_safe_SVAL(param,tpscnt,p,0,-1); cli_buf_size= get_safe_SVAL(param,tpscnt,p,2,0); DEBUG(10,("api_RNetUserEnum:resume context: %d, client buffer size: %d\n", @@ -2301,6 +2303,7 @@ static bool api_RNetUserEnum(connection_struct *conn, uint16 vuid, } p = *rdata; + endp = *rdata + *rdata_len; become_root(); search = pdb_search_users(ACB_NORMAL); @@ -2319,13 +2322,13 @@ static bool api_RNetUserEnum(connection_struct *conn, uint16 vuid, for (i=0; i= 10) { SIVAL(p,usri11_comment,PTR_DIFF(p2,p)); /* comment */ - pstrcpy(p2,"Comment"); + strlcpy(p2,"Comment",PTR_DIFF(endp,p2)); p2 = skip_string(*rdata,*rdata_len,p2); if (!p2) { return False; } SIVAL(p,usri11_usr_comment,PTR_DIFF(p2,p)); /* user_comment */ - pstrcpy(p2,"UserComment"); + strlcpy(p2,"UserComment",PTR_DIFF(endp,p2)); p2 = skip_string(*rdata,*rdata_len,p2); if (!p2) { return False; @@ -3385,7 +3393,7 @@ static bool api_RNetUserGetInfo(connection_struct *conn, uint16 vuid, /* EEK! the cifsrap.txt doesn't have this in!!!! */ SIVAL(p,usri11_full_name,PTR_DIFF(p2,p)); /* full name */ - pstrcpy(p2,((vuser != NULL) ? vuser->user.full_name : UserName)); + strlcpy(p2,((vuser != NULL) ? vuser->user.full_name : UserName),PTR_DIFF(endp,p2)); p2 = skip_string(*rdata,*rdata_len,p2); if (!p2) { return False; @@ -3398,13 +3406,13 @@ static bool api_RNetUserGetInfo(connection_struct *conn, uint16 vuid, SIVAL(p,usri11_auth_flags,AF_OP_PRINT); /* auth flags */ SIVALS(p,usri11_password_age,-1); /* password age */ SIVAL(p,usri11_homedir,PTR_DIFF(p2,p)); /* home dir */ - pstrcpy(p2, vuser && vuser->homedir ? vuser->homedir : ""); + strlcpy(p2, vuser && vuser->homedir ? vuser->homedir : "",PTR_DIFF(endp,p2)); p2 = skip_string(*rdata,*rdata_len,p2); if (!p2) { return False; } SIVAL(p,usri11_parms,PTR_DIFF(p2,p)); /* parms */ - pstrcpy(p2,""); + strlcpy(p2,"",PTR_DIFF(endp,p2)); p2 = skip_string(*rdata,*rdata_len,p2); if (!p2) { return False; @@ -3414,7 +3422,7 @@ static bool api_RNetUserGetInfo(connection_struct *conn, uint16 vuid, SSVALS(p,usri11_bad_pw_count,-1); /* bad pw counts */ SSVALS(p,usri11_num_logons,-1); /* num logons */ SIVAL(p,usri11_logon_server,PTR_DIFF(p2,p)); /* logon server */ - pstrcpy(p2,"\\\\*"); + strlcpy(p2,"\\\\*",PTR_DIFF(endp,p2)); p2 = skip_string(*rdata,*rdata_len,p2); if (!p2) { return False; @@ -3422,7 +3430,7 @@ static bool api_RNetUserGetInfo(connection_struct *conn, uint16 vuid, SSVAL(p,usri11_country_code,0); /* country code */ SIVAL(p,usri11_workstations,PTR_DIFF(p2,p)); /* workstations */ - pstrcpy(p2,""); + strlcpy(p2,"",PTR_DIFF(endp,p2)); p2 = skip_string(*rdata,*rdata_len,p2); if (!p2) { return False; @@ -3449,7 +3457,7 @@ static bool api_RNetUserGetInfo(connection_struct *conn, uint16 vuid, SSVAL(p,42, conn->admin_user?USER_PRIV_ADMIN:USER_PRIV_USER); SIVAL(p,44,PTR_DIFF(p2,*rdata)); /* home dir */ - pstrcpy(p2, vuser && vuser->homedir ? vuser->homedir : ""); + strlcpy(p2, vuser && vuser->homedir ? vuser->homedir : "",PTR_DIFF(endp,p2)); p2 = skip_string(*rdata,*rdata_len,p2); if (!p2) { return False; @@ -3458,7 +3466,7 @@ static bool api_RNetUserGetInfo(connection_struct *conn, uint16 vuid, *p2++ = 0; SSVAL(p,52,0); /* flags */ SIVAL(p,54,PTR_DIFF(p2,*rdata)); /* script_path */ - pstrcpy(p2,vuser && vuser->logon_script ? vuser->logon_script : ""); + strlcpy(p2,vuser && vuser->logon_script ? vuser->logon_script : "",PTR_DIFF(endp,p2)); p2 = skip_string(*rdata,*rdata_len,p2); if (!p2) { return False; @@ -3466,14 +3474,14 @@ static bool api_RNetUserGetInfo(connection_struct *conn, uint16 vuid, if (uLevel == 2) { SIVAL(p,60,0); /* auth_flags */ SIVAL(p,64,PTR_DIFF(p2,*rdata)); /* full_name */ - pstrcpy(p2,((vuser != NULL) ? vuser->user.full_name : UserName)); + strlcpy(p2,((vuser != NULL) ? vuser->user.full_name : UserName),PTR_DIFF(endp,p2)); p2 = skip_string(*rdata,*rdata_len,p2); if (!p2) { return False; } SIVAL(p,68,0); /* urs_comment */ SIVAL(p,72,PTR_DIFF(p2,*rdata)); /* parms */ - pstrcpy(p2,""); + strlcpy(p2,"",PTR_DIFF(endp,p2)); p2 = skip_string(*rdata,*rdata_len,p2); if (!p2) { return False; -- cgit