svn commit: samba r16745 - in trunk/source: include lib libads libndr locking nsswitch utils

vlendec at samba.org vlendec at samba.org
Sat Jul 1 15:25:24 GMT 2006


Author: vlendec
Date: 2006-07-01 15:25:21 +0000 (Sat, 01 Jul 2006)
New Revision: 16745

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16745

Log:
Fix all but three type-punned warnings. 

I can really understand the compiler freaks out about smbd/vfs.c:107, but
changing that is bigger...

The other two ones are in auth/auth_winbind.c:160 and
auth/auth_script.c:135. Need to look more at those.

Volker

Modified:
   trunk/source/include/smb_macros.h
   trunk/source/lib/charcnv.c
   trunk/source/lib/util.c
   trunk/source/libads/ldap.c
   trunk/source/libndr/ndr_string.c
   trunk/source/locking/brlock.c
   trunk/source/nsswitch/pam_winbind.c
   trunk/source/nsswitch/winbindd_async.c
   trunk/source/utils/net_ads.c
   trunk/source/utils/net_rpc_samsync.c
   trunk/source/utils/ntlm_auth_diagnostics.c


Changeset:
Modified: trunk/source/include/smb_macros.h
===================================================================
--- trunk/source/include/smb_macros.h	2006-07-01 15:22:18 UTC (rev 16744)
+++ trunk/source/include/smb_macros.h	2006-07-01 15:25:21 UTC (rev 16745)
@@ -376,6 +376,6 @@
 } while (0)
 
 #define ADD_TO_LARGE_ARRAY(mem_ctx, type, elem, array, num, size) \
-	add_to_large_array((mem_ctx), sizeof(type), &(elem), (void **)(array), (num), (size));
+	add_to_large_array((mem_ctx), sizeof(type), &(elem), (void *)(array), (num), (size));
 
 #endif /* _SMB_MACROS_H */

Modified: trunk/source/lib/charcnv.c
===================================================================
--- trunk/source/lib/charcnv.c	2006-07-01 15:22:18 UTC (rev 16744)
+++ trunk/source/lib/charcnv.c	2006-07-01 15:25:21 UTC (rev 16745)
@@ -704,8 +704,10 @@
  * @returns Size in bytes of the converted string; or -1 in case of error.
  **/
 size_t convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
-		      		void const *src, size_t srclen, void **dest, BOOL allow_bad_conv)
+			     void const *src, size_t srclen, void *dst,
+			     BOOL allow_bad_conv)
 {
+	void **dest = (void **)dst;
 	size_t dest_len;
 
 	*dest = NULL;
@@ -945,9 +947,9 @@
 
 	if (flags & STR_TERMINATE) {
 		if (src_len == (size_t)-1) {
-			src_len = strlen(src) + 1;
+			src_len = strlen((const char *)src) + 1;
 		} else {
-			size_t len = strnlen(src, src_len);
+			size_t len = strnlen((const char *)src, src_len);
 			if (len < src_len)
 				len++;
 			src_len = len;
@@ -1035,7 +1037,7 @@
 	len += ret;
 
 	if (flags & STR_UPPER) {
-		smb_ucs2_t *dest_ucs2 = dest;
+		smb_ucs2_t *dest_ucs2 = (smb_ucs2_t *)dest;
 		size_t i;
 		for (i = 0; i < (dest_len / 2) && dest_ucs2[i]; i++) {
 			smb_ucs2_t v = toupper_w(dest_ucs2[i]);
@@ -1179,7 +1181,8 @@
 	if (flags & STR_TERMINATE) {
 		/* src_len -1 is the default for null terminated strings. */
 		if (src_len != (size_t)-1) {
-			size_t len = strnlen_w(src, src_len/2);
+			size_t len = strnlen_w((const smb_ucs2_t *)src,
+						src_len/2);
 			if (len < src_len/2)
 				len++;
 			src_len = len*2;

Modified: trunk/source/lib/util.c
===================================================================
--- trunk/source/lib/util.c	2006-07-01 15:22:18 UTC (rev 16744)
+++ trunk/source/lib/util.c	2006-07-01 15:25:21 UTC (rev 16745)
@@ -753,7 +753,7 @@
 	size_t num_to_read_thistime;
 	size_t num_written = 0;
 
-	if ((buf = SMB_MALLOC(TRANSFER_BUF_SIZE)) == NULL)
+	if ((buf = SMB_MALLOC_ARRAY(char, TRANSFER_BUF_SIZE)) == NULL)
 		return -1;
 
 	while (total < n) {
@@ -1052,9 +1052,11 @@
 ****************************************************************************/
 
 void add_to_large_array(TALLOC_CTX *mem_ctx, size_t element_size,
-			void *element, void **array, uint32 *num_elements,
+			void *element, void *_array, uint32 *num_elements,
 			ssize_t *array_size)
 {
+	void **array = (void **)_array;
+
 	if (*array_size < 0) {
 		return;
 	}

Modified: trunk/source/libads/ldap.c
===================================================================
--- trunk/source/libads/ldap.c	2006-07-01 15:22:18 UTC (rev 16744)
+++ trunk/source/libads/ldap.c	2006-07-01 15:25:21 UTC (rev 16745)
@@ -828,10 +828,11 @@
  * @param attrs Attributes to retrieve
  * @return status of search
  **/
-ADS_STATUS ads_search_dn(ADS_STRUCT *ads, void **res, 
+ADS_STATUS ads_search_dn(ADS_STRUCT *ads, void *_res, 
 			 const char *dn, 
 			 const char **attrs)
 {
+	void **res = (void **)_res;
 	return ads_do_search(ads, dn, LDAP_SCOPE_BASE, "(objectclass=*)", attrs, res);
 }
 
@@ -970,8 +971,9 @@
 */
 static ADS_STATUS ads_modlist_add(TALLOC_CTX *ctx, ADS_MODLIST *mods, 
 				  int mod_op, const char *name, 
-				  const void **invals)
+				  const void *_invals)
 {
+	const void **invals = (const void **)_invals;
 	int curmod;
 	LDAPMod **modlist = (LDAPMod **) *mods;
 	struct berval **ber_values = NULL;
@@ -1034,8 +1036,7 @@
 
 	if (!val)
 		return ads_modlist_add(ctx, mods, LDAP_MOD_DELETE, name, NULL);
-	return ads_modlist_add(ctx, mods, LDAP_MOD_REPLACE, name, 
-			       (const void **) values);
+	return ads_modlist_add(ctx, mods, LDAP_MOD_REPLACE, name, values);
 }
 
 /**

Modified: trunk/source/libndr/ndr_string.c
===================================================================
--- trunk/source/libndr/ndr_string.c	2006-07-01 15:22:18 UTC (rev 16744)
+++ trunk/source/libndr/ndr_string.c	2006-07-01 15:25:21 UTC (rev 16745)
@@ -83,7 +83,7 @@
 						    chset, CH_UNIX, 
 						    ndr->data+ndr->offset, 
 						    (len2 + c_len_term)*byte_mul,
-						    (void **)&as, True);
+						    &as, True);
 			if (ret == -1) {
 				return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 
 						      "Bad character conversion");
@@ -120,7 +120,7 @@
 						    chset, CH_UNIX, 
 						    ndr->data+ndr->offset, 
 						    (len1 + c_len_term)*byte_mul,
-						    (void **)&as, False);
+						    &as, False);
 			if (ret == -1) {
 				return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 
 						      "Bad character conversion");
@@ -158,7 +158,7 @@
 						    chset, CH_UNIX, 
 						    ndr->data+ndr->offset, 
 						    (len1 + c_len_term)*byte_mul,
-						    (void **)&as, False);
+						    &as, False);
 			if (ret == -1) {
 				return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 
 						      "Bad character conversion");
@@ -192,7 +192,7 @@
 						    chset, CH_UNIX, 
 						    ndr->data+ndr->offset, 
 						    (len3 + c_len_term)*byte_mul,
-						    (void **)&as, False);
+						    &as, False);
 			if (ret == -1) {
 				return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 
 						      "Bad character conversion");
@@ -223,8 +223,7 @@
 			ret = convert_string_talloc(ndr->current_mem_ctx,
 						    chset, CH_UNIX, 
 						    ndr->data+ndr->offset, 
-						    len3,
-						    (void **)&as, False);
+						    len3, &as, False);
 			if (ret == -1) {
 				return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 
 						      "Bad character conversion");
@@ -243,8 +242,7 @@
 		ret = convert_string_talloc(ndr->current_mem_ctx,
 					    chset, CH_UNIX, 
 					    ndr->data+ndr->offset, 
-					    len1,
-					    (void **)&as, False);
+					    len1, &as, False);
 		if (ret == -1) {
 			return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 
 					      "Bad character conversion");
@@ -260,8 +258,7 @@
 		ret = convert_string_talloc(ndr->current_mem_ctx,
 					    chset, CH_UNIX, 
 					    ndr->data+ndr->offset, 
-					    len1*byte_mul,
-					    (void **)&as, False);
+					    len1*byte_mul, &as, False);
 		if (ret == -1) {
 			return ndr_pull_error(ndr, NDR_ERR_CHARCNV, 
 					      "Bad character conversion");
@@ -318,7 +315,8 @@
 	       LIBNDR_FLAG_STR_FIXLEN32))) {
 		s_len++;
 	}
-	d_len = convert_string_talloc(ndr, CH_UNIX, chset, s, s_len, (void **)&dest, False);
+	d_len = convert_string_talloc(ndr, CH_UNIX, chset, s, s_len, &dest,
+				      False);
 	if (d_len == -1) {
 		return ndr_push_error(ndr, NDR_ERR_CHARCNV, 
 				      "Bad character conversion");
@@ -522,7 +520,7 @@
 {
 	uint32_t i;
 	uint8_t zero[4] = {0,0,0,0};
-	const char *var = _var;
+	const char *var = (const char *)_var;
 
 	for (i = 0; memcmp(var+i*element_size,zero,element_size) != 0; i++);
 
@@ -609,5 +607,5 @@
 {
 	/* FIXME: Treat special chars special here, taking chset into account */
 	/* Also include 0 byte */
-	return strlen(var)+1;
+	return strlen((const char *)var)+1;
 }

Modified: trunk/source/locking/brlock.c
===================================================================
--- trunk/source/locking/brlock.c	2006-07-01 15:22:18 UTC (rev 16744)
+++ trunk/source/locking/brlock.c	2006-07-01 15:25:21 UTC (rev 16745)
@@ -1468,13 +1468,23 @@
 		/* Go through and ensure all entries exist - remove any that don't. */
 		/* Makes the lockdb self cleaning at low cost. */
 
-		if (!validate_lock_entries(&br_lck->num_locks, (struct lock_struct **)&br_lck->lock_data)) {
+		struct lock_struct *locks =
+			(struct lock_struct *)br_lck->lock_data;
+
+		if (!validate_lock_entries(&br_lck->num_locks, &locks)) {
 			tdb_chainunlock(tdb, key);
 			SAFE_FREE(br_lck->lock_data);
 			TALLOC_FREE(br_lck);
 			return NULL;
 		}
 
+		/*
+		 * validate_lock_entries might have changed locks. We can't
+		 * use a direct pointer here because otherwise gcc warnes
+		 * about strict aliasing rules being violated.
+		 */
+		br_lck->lock_data = locks;
+
 		/* Mark the lockdb as "clean" as seen from this open file. */
 		fsp->lockdb_clean = True;
 	}

Modified: trunk/source/nsswitch/pam_winbind.c
===================================================================
--- trunk/source/nsswitch/pam_winbind.c	2006-07-01 15:22:18 UTC (rev 16744)
+++ trunk/source/nsswitch/pam_winbind.c	2006-07-01 15:25:21 UTC (rev 16745)
@@ -128,6 +128,24 @@
 	SAFE_FREE(data);
 }
 
+/*
+ * Work around the pam API that has functions with void ** as parameters.
+ * These lead to strict aliasing warnings with gcc.
+ */
+static int _pam_get_item(const pam_handle_t *pamh, int item_type,
+			 const void *_item)
+{
+	const void **item = (const void **)_item;
+	return pam_get_item(pamh, item_type, item);
+}
+static int _pam_get_data(const pam_handle_t *pamh,
+			 const char *module_data_name, const void *_data)
+{
+	const void **data = (const void **)_data;
+	return pam_get_data(pamh, module_data_name, data);
+}
+
+
 static const struct ntstatus_errors {
 	const char *ntstatus_string;
 	const char *error_string;
@@ -173,7 +191,7 @@
 	int retval;
 	struct pam_conv *conv;
 
-	retval = pam_get_item(pamh, PAM_CONV, (const void **) &conv );
+	retval = _pam_get_item(pamh, PAM_CONV, &conv );
 	if (retval == PAM_SUCCESS) {
 		retval = conv->conv(nargs, (const struct pam_message **)message,
 				    response, conv->appdata_ptr);
@@ -676,7 +694,7 @@
 	 */
 
 	if (on(WINBIND_TRY_FIRST_PASS_ARG, ctrl) || on(WINBIND_USE_FIRST_PASS_ARG, ctrl)) {
-		retval = pam_get_item(pamh, authtok_flag, (const void **) &item);
+		retval = _pam_get_item(pamh, authtok_flag, &item);
 		if (retval != PAM_SUCCESS) {
 			/* very strange. */
 			_pam_log(LOG_ALERT, 
@@ -778,7 +796,7 @@
 	retval = pam_set_item(pamh, authtok_flag, token);
 	_pam_delete(token);	/* clean it up */
 	if (retval != PAM_SUCCESS || 
-	    (retval = pam_get_item(pamh, authtok_flag, (const void **) &item)) != PAM_SUCCESS) {
+	    (retval = _pam_get_item(pamh, authtok_flag, &item)) != PAM_SUCCESS) {
 		
 		_pam_log(LOG_CRIT, "error manipulating password");
 		return retval;
@@ -1251,8 +1269,7 @@
 		 * get the old token back. 
 		 */
 		
-		retval = pam_get_item(pamh, PAM_OLDAUTHTOK,
-				      (const void **) &pass_old);
+		retval = _pam_get_item(pamh, PAM_OLDAUTHTOK, &pass_old);
 		
 		if (retval != PAM_SUCCESS) {
 			_pam_log(LOG_NOTICE, "user not authenticated");
@@ -1300,7 +1317,8 @@
 		 * By reaching here we have approved the passwords and must now
 		 * rebuild the password database file.
 		 */
-		pam_get_data( pamh, PAM_WINBIND_PWD_LAST_SET, (const void **)&pwdlastset_update);
+		_pam_get_data( pamh, PAM_WINBIND_PWD_LAST_SET,
+			       &pwdlastset_update);
 
 		retval = winbind_chauthtok_request(pamh, ctrl, user, pass_old, pass_new, pwdlastset_update);
 		if (retval) {

Modified: trunk/source/nsswitch/winbindd_async.c
===================================================================
--- trunk/source/nsswitch/winbindd_async.c	2006-07-01 15:22:18 UTC (rev 16744)
+++ trunk/source/nsswitch/winbindd_async.c	2006-07-01 15:25:21 UTC (rev 16745)
@@ -985,12 +985,15 @@
 		add_sid_to_array(state->mem_ctx, &sid, &sids, &num_sids);
 	}
 
-	if (!print_sidlist(NULL, sids, num_sids,
-			   (char **)&state->response.extra_data.data, &len)) {
+
+	if (!print_sidlist(NULL, sids, num_sids, &sidstr, &len)) {
 		DEBUG(0, ("Could not print_sidlist\n"));
+		state->response.extra_data.data = NULL;
 		return WINBINDD_ERROR;
 	}
 
+	state->response.extra_data.data = sidstr;
+
 	if (state->response.extra_data.data != NULL) {
 		DEBUG(10, ("aliases_list: %s\n",
 			   (char *)state->response.extra_data.data));

Modified: trunk/source/utils/net_ads.c
===================================================================
--- trunk/source/utils/net_ads.c	2006-07-01 15:22:18 UTC (rev 16744)
+++ trunk/source/utils/net_ads.c	2006-07-01 15:25:21 UTC (rev 16745)
@@ -1011,7 +1011,7 @@
 	asprintf(&dn, "%s,%s", ou_str, ads->config.bind_path);
 	free(ou_str);
 
-	rc = ads_search_dn(ads, (void**)&res, dn, NULL);
+	rc = ads_search_dn(ads, &res, dn, NULL);
 	ads_msgfree(ads, res);
 
 	if (ADS_ERR_OK(rc)) {

Modified: trunk/source/utils/net_rpc_samsync.c
===================================================================
--- trunk/source/utils/net_rpc_samsync.c	2006-07-01 15:22:18 UTC (rev 16744)
+++ trunk/source/utils/net_rpc_samsync.c	2006-07-01 15:25:21 UTC (rev 16745)
@@ -42,7 +42,7 @@
 	d_printf("\n");
 }
 
-static const char *display_time(NTTIME *nttime)
+static const char *display_time(const UINT64_S *nttime)
 {
 	static fstring string;
 
@@ -123,11 +123,19 @@
 	       pdb_encode_acct_ctrl(a->acb_info, NEW_PW_FORMAT_SPACE_PADDED_LEN));
 }
 
+static time_t uint64s_nt_time_to_unix_abs(const UINT64_S *src)
+{
+	NTTIME nttime;
+	nttime.high = src->high;
+	nttime.low = src->low;
+	return nt_time_to_unix_abs(&nttime);
+}
+
 static void display_domain_info(SAM_DOMAIN_INFO *a)
 {
 	time_t u_logout;
 
-	u_logout = nt_time_to_unix_abs((NTTIME *)&a->force_logoff);
+	u_logout = uint64s_nt_time_to_unix_abs(&a->force_logoff);
 
 	d_printf("Domain name: %s\n", unistr2_static(&a->uni_dom_name));
 
@@ -136,11 +144,11 @@
 
 	d_printf("Force Logoff: %d\n", (int)u_logout);
 
-	d_printf("Max Password Age: %s\n", display_time((NTTIME *)&a->max_pwd_age));
-	d_printf("Min Password Age: %s\n", display_time((NTTIME *)&a->min_pwd_age));
+	d_printf("Max Password Age: %s\n", display_time(&a->max_pwd_age));
+	d_printf("Min Password Age: %s\n", display_time(&a->min_pwd_age));
 
-	d_printf("Lockout Time: %s\n", display_time((NTTIME *)&a->account_lockout.lockout_duration));
-	d_printf("Lockout Reset Time: %s\n", display_time((NTTIME *)&a->account_lockout.reset_count));
+	d_printf("Lockout Time: %s\n", display_time(&a->account_lockout.lockout_duration));
+	d_printf("Lockout Reset Time: %s\n", display_time(&a->account_lockout.reset_count));
 
 	d_printf("Bad Attempt Lockout: %d\n", a->account_lockout.bad_attempt_lockout);
 	d_printf("User must logon to change password: %d\n", a->logon_chgpass);
@@ -858,11 +866,11 @@
 	NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
 	pstring domname;
 
-	u_max_age = nt_time_to_unix_abs((NTTIME *)&delta->max_pwd_age);
-	u_min_age = nt_time_to_unix_abs((NTTIME *)&delta->min_pwd_age);
-	u_logout = nt_time_to_unix_abs((NTTIME *)&delta->force_logoff);
-	u_lockoutreset = nt_time_to_unix_abs((NTTIME *)&delta->account_lockout.reset_count);
-	u_lockouttime = nt_time_to_unix_abs((NTTIME *)&delta->account_lockout.lockout_duration);
+	u_max_age = uint64s_nt_time_to_unix_abs(&delta->max_pwd_age);
+	u_min_age = uint64s_nt_time_to_unix_abs(&delta->min_pwd_age);
+	u_logout = uint64s_nt_time_to_unix_abs(&delta->force_logoff);
+	u_lockoutreset = uint64s_nt_time_to_unix_abs(&delta->account_lockout.reset_count);
+	u_lockouttime = uint64s_nt_time_to_unix_abs(&delta->account_lockout.lockout_duration);
 
 	unistr2_to_ascii(domname, &delta->uni_dom_name, sizeof(domname) - 1);
 

Modified: trunk/source/utils/ntlm_auth_diagnostics.c
===================================================================
--- trunk/source/utils/ntlm_auth_diagnostics.c	2006-07-01 15:22:18 UTC (rev 16744)
+++ trunk/source/utils/ntlm_auth_diagnostics.c	2006-07-01 15:25:21 UTC (rev 16745)
@@ -445,6 +445,7 @@
 	DATA_BLOB nt_response = data_blob(NULL, 0);
 	DATA_BLOB lm_response = data_blob(NULL, 0);
 	char *password;
+	smb_ucs2_t *nt_response_ucs2;
 
 	uchar user_session_key[16];
 	uchar lm_key[16];
@@ -457,12 +458,13 @@
 	flags |= WBFLAG_PAM_LMKEY;
 	flags |= WBFLAG_PAM_USER_SESSION_KEY;
 
-	if ((push_ucs2_allocate((smb_ucs2_t **)&nt_response.data, opt_password)) == -1) {
+	if ((push_ucs2_allocate(&nt_response_ucs2, opt_password)) == -1) {
 		DEBUG(0, ("push_ucs2_allocate failed!\n"));
 		exit(1);
 	}
 
-	nt_response.length = strlen_w(((void *)nt_response.data))*sizeof(smb_ucs2_t);
+	nt_response.data = (unsigned char *)nt_response_ucs2;
+	nt_response.length = strlen_w(nt_response_ucs2)*sizeof(smb_ucs2_t);
 
 	if ((password = strdup_upper(opt_password)) == NULL) {
 		DEBUG(0, ("strdup_upper failed!\n"));
@@ -472,7 +474,7 @@
 	if ((convert_string_allocate(NULL, CH_UNIX, 
 				     CH_DOS, password,
 				     strlen(password)+1, 
-				     (void**)&lm_response.data,True)) == -1) {
+				     &lm_response.data,True)) == -1) {
 		DEBUG(0, ("convert_string_allocate failed!\n"));
 		exit(1);
 	}



More information about the samba-cvs mailing list