aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-12-21 14:22:10 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-12-21 14:22:10 +0000
commita173e07eec19b49af0f3f32f636768eee653ebbf (patch)
tree6e408ec31dd1e662cb293fabbe96bb030e7a341e
parent3de85777de18811cbff6999e94a168ee067b3bea (diff)
Prevent failf() from using the va_list variable more than once.
See bug report #1088962 and Single Unix Specification: http://www.opengroup.org/onlinepubs/007908799/xsh/vfprintf.html
-rw-r--r--lib/sendf.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/sendf.c b/lib/sendf.c
index 175323903..91671b95e 100644
--- a/lib/sendf.c
+++ b/lib/sendf.c
@@ -155,21 +155,21 @@ void Curl_failf(struct SessionHandle *data, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
+ size_t len;
+
+ vsnprintf(data->state.buffer, BUFSIZE, fmt, ap);
+
if(data->set.errorbuffer && !data->state.errorbuf) {
- vsnprintf(data->set.errorbuffer, CURL_ERROR_SIZE, fmt, ap);
+ snprintf(data->set.errorbuffer, CURL_ERROR_SIZE, "%s", data->state.buffer);
data->state.errorbuf = TRUE; /* wrote error string */
}
if(data->set.verbose) {
- size_t len;
-
- vsnprintf(data->state.buffer, BUFSIZE, fmt, ap);
- len = strlen(data->state.buffer);
-
- if(len < BUFSIZE - 1) {
- data->state.buffer[len] = '\n';
- data->state.buffer[++len] = '\0';
- }
- Curl_debug(data, CURLINFO_TEXT, data->state.buffer, len, NULL);
+ len = strlen(data->state.buffer);
+ if(len < BUFSIZE - 1) {
+ data->state.buffer[len] = '\n';
+ data->state.buffer[++len] = '\0';
+ }
+ Curl_debug(data, CURLINFO_TEXT, data->state.buffer, len, NULL);
}
va_end(ap);