summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2006-06-27 02:30:58 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:18:59 -0500
commit9718506d35ca14c5233b613c647609bf2589f38b (patch)
tree49ce9dccfaeb36d4253b30d9dc870bd9ebd703d4
parentad6f4f14ad10dab330e51ad36f8f8d6ccc065be2 (diff)
downloadsamba-9718506d35ca14c5233b613c647609bf2589f38b.tar.gz
samba-9718506d35ca14c5233b613c647609bf2589f38b.tar.bz2
samba-9718506d35ca14c5233b613c647609bf2589f38b.zip
r16550: Fix bug 3866. Thanks for the report!
Although I've never met a computer or compiler that produced pointers to functions which are a different size than pointers to data, I suppose they probably exist. Assigning a pointer to a function is technically illegal in C anyway. Change casts of the option_value based on the option_name to use of variable argument lists. For binary compatibility, I've maintained but deprecated the old behavior of debug_stderr (which expected to be passed a NULL or non-NULL pointer) and added a new option debug_to_stderr which properly expects a boolean (int) parameter. Derrell (This used to be commit c1b4c510530ca3118d1eccb9615a8cad732c7373)
-rw-r--r--examples/libsmbclient/testbrowse.c4
-rw-r--r--source3/include/libsmbclient.h2
-rw-r--r--source3/libsmb/libsmbclient.c47
3 files changed, 44 insertions, 9 deletions
diff --git a/examples/libsmbclient/testbrowse.c b/examples/libsmbclient/testbrowse.c
index 96f78aad85..562d2c2aeb 100644
--- a/examples/libsmbclient/testbrowse.c
+++ b/examples/libsmbclient/testbrowse.c
@@ -120,10 +120,10 @@ main(int argc, char * argv[])
(no_auth ? no_auth_data_fn : get_auth_data_fn);
}
- /* If we've been asked to log to stderr instead of stdout... */
+ /* If we've been asked to log to stderr instead of stdout, ... */
if (debug_stderr) {
/* ... then set the option to do so */
- smbc_option_set(context, "debug_stderr", (void *) 1);
+ smbc_option_set(context, "debug_to_stderr", 1);
}
/* Initialize the context using the previously specified options */
diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h
index ba92259f70..66a567a0d5 100644
--- a/source3/include/libsmbclient.h
+++ b/source3/include/libsmbclient.h
@@ -635,7 +635,7 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
void
smbc_option_set(SMBCCTX *context,
char *option_name,
- void *option_value);
+ ... /* option_value */);
/*
* Retrieve the current value of an option
*
diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c
index 98264dfa86..7f41103e4f 100644
--- a/source3/libsmb/libsmbclient.c
+++ b/source3/libsmb/libsmbclient.c
@@ -236,7 +236,7 @@ smbc_urlencode(char * dest, char * src, int max_dest_len)
*
*
* We accept:
- * smb://[[[domain;]user[:password@]]server[/share[/path[/file]]]][?options]
+ * smb://[[[domain;]user[:password]@]server[/share[/path[/file]]]][?options]
*
* Meaning of URLs:
*
@@ -6003,27 +6003,62 @@ smbc_free_context(SMBCCTX *context,
void
smbc_option_set(SMBCCTX *context,
char *option_name,
- void *option_value)
+ ... /* option_value */)
{
- if (strcmp(option_name, "debug_stderr") == 0) {
+ va_list ap;
+ union {
+ BOOL b;
+ smbc_get_auth_data_with_context_fn auth_fn;
+ void *v;
+ } option_value;
+
+ va_start(ap, option_name);
+
+ if (strcmp(option_name, "debug_to_stderr") == 0) {
/*
* Log to standard error instead of standard output.
*/
+ option_value.b = (BOOL) va_arg(ap, int);
+ context->internal->_debug_stderr = option_value.b;
+
+ } else if (strcmp(option_name, "debug_to_stderr") == 0) {
+ /*
+ * Log to standard error instead of standard output.
+ *
+ * This function used to take a third parameter,
+ * void *option_value. Since it was a void* and we needed to
+ * pass a boolean, a boolean value was cast to void* to be
+ * passed in. Now that we're using a va_list to retrieve the
+ * parameters, the casting kludge is unnecessary.
+ *
+ * WARNING: DO NOT USE THIS OPTION.
+ * This option is retained for backward compatibility. New
+ * applications should use "debug_to_stderr" and properly pass
+ * in a boolean (int) value.
+ */
+ option_value.v = va_arg(ap, void *);
context->internal->_debug_stderr =
- (option_value == NULL ? False : True);
+ (option_value.v == NULL ? False : True);
+
} else if (strcmp(option_name, "auth_function") == 0) {
/*
* Use the new-style authentication function which includes
* the context.
*/
- context->internal->_auth_fn_with_context = option_value;
+ option_value.auth_fn =
+ va_arg(ap, smbc_get_auth_data_with_context_fn);
+ context->internal->_auth_fn_with_context =
+ option_value.auth_fn;
} else if (strcmp(option_name, "user_data") == 0) {
/*
* Save a user data handle which may be retrieved by the user
* with smbc_option_get()
*/
- context->internal->_user_data = option_value;
+ option_value.v = va_arg(ap, void *);
+ context->internal->_user_data = option_value.v;
}
+
+ va_end(ap);
}