[dovecot-cvs] dovecot/src/lib failures.c,1.14,1.15 macros.h,1.8,1.9 str.c,1.4,1.5 strfuncs.c,1.24,1.25
cras at procontrol.fi
cras at procontrol.fi
Fri Dec 27 18:02:27 EET 2002
Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv476/src/lib
Modified Files:
failures.c macros.h str.c strfuncs.c
Log Message:
We weren't using va_list properly, especially gcc/PowerPC didn't like it.
Index: failures.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/failures.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- failures.c 22 Dec 2002 08:03:03 -0000 1.14
+++ failures.c 27 Dec 2002 16:02:25 -0000 1.15
@@ -83,6 +83,7 @@
const char *format, va_list args)
{
static int recursed = 0;
+ va_list args2;
int old_errno = errno;
if (recursed == 2) {
@@ -100,6 +101,8 @@
log_fd = stderr;
}
+ VA_COPY(args2, args);
+
t_push();
if (recursed == 2) {
/* write without fixing format, that probably killed us
@@ -107,7 +110,7 @@
/* make sure there's no %n in there */
(void)printf_string_upper_bound(format, args);
- vfprintf(f, format, args);
+ vfprintf(f, format, args2);
fputs(" - recursed!", f);
} else {
write_prefix(f);
@@ -116,7 +119,7 @@
format = printf_string_fix_format(format);
/* make sure there's no %n in there */
(void)printf_string_upper_bound(format, args);
- vfprintf(f, format, args);
+ vfprintf(f, format, args2);
}
fputc('\n', f);
@@ -270,6 +273,8 @@
static void syslog_handler(int level, const char *format, va_list args)
{
+ va_list args2;
+
static int recursed = 0;
if (recursed != 0)
@@ -278,9 +283,10 @@
recursed++;
/* make sure there's no %n in there */
+ VA_COPY(args2, args);
(void)printf_string_upper_bound(format, args);
- vsyslog(level, format, args);
+ vsyslog(level, format, args2);
recursed--;
}
Index: macros.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/macros.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- macros.h 4 Nov 2002 07:11:32 -0000 1.8
+++ macros.h 27 Dec 2002 16:02:25 -0000 1.9
@@ -40,7 +40,8 @@
#define POINTER_CAST_TO(p, type) \
((type) ((const char *) (p) - (const char *) NULL))
-/* Define VA_COPY() to do the right thing for copying va_list variables. */
+/* Define VA_COPY() to do the right thing for copying va_list variables.
+ config.h may have already defined VA_COPY as va_copy or __va_copy. */
#ifndef VA_COPY
# if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
# define VA_COPY(ap1, ap2) (*(ap1) = *(ap2))
Index: str.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/str.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- str.c 22 Dec 2002 07:06:16 -0000 1.4
+++ str.c 27 Dec 2002 16:02:25 -0000 1.5
@@ -123,8 +123,11 @@
{
char *buf;
int ret;
+ va_list args2;
size_t len, append_len;
+ VA_COPY(args2, args);
+
len = buffer_get_used_size(str);
fmt = printf_string_fix_format(fmt);
@@ -133,10 +136,10 @@
buf = buffer_append_space(str, append_len);
#ifdef HAVE_VSNPRINTF
- ret = vsnprintf(buf, append_len, fmt, args);
+ ret = vsnprintf(buf, append_len, fmt, args2);
i_assert(ret >= 0 && (size_t)ret <= append_len);
#else
- ret = vsprintf(buf, fmt, args);
+ ret = vsprintf(buf, fmt, args2);
i_assert(ret >= 0);
#endif
Index: strfuncs.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/strfuncs.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- strfuncs.c 22 Dec 2002 08:18:29 -0000 1.24
+++ strfuncs.c 27 Dec 2002 16:02:25 -0000 1.25
@@ -97,7 +97,7 @@
#ifndef HAVE_VSNPRINTF
char *buf;
#endif
- va_list args;
+ va_list args, args2;
ssize_t len;
int ret;
@@ -106,18 +106,21 @@
t_push();
va_start(args, format);
+ VA_COPY(args2, args);
+
format = printf_string_fix_format(format);
len = printf_string_upper_bound(format, args);
- va_end(args);
i_assert(len >= 0);
#ifdef HAVE_VSNPRINTF
- len = vsnprintf(dest, max_chars, format, args);
+ len = vsnprintf(dest, max_chars, format, args2);
#else
buf = t_buffer_get(len);
- len = vsprintf(buf, format, args);
+ len = vsprintf(buf, format, args2);
#endif
+ va_end(args);
+
if (len < 0) {
/* some error occured */
len = 0;
@@ -213,6 +216,7 @@
char *p_strdup_vprintf(Pool pool, const char *format, va_list args)
{
char *ret;
+ va_list args2;
size_t len;
i_assert(format != NULL);
@@ -220,15 +224,17 @@
if (pool != data_stack_pool)
t_push();
+ VA_COPY(args2, args);
+
format = printf_string_fix_format(format);
len = printf_string_upper_bound(format, args);
ret = p_malloc(pool, len);
#ifdef HAVE_VSNPRINTF
- vsnprintf(ret, len, format, args);
+ vsnprintf(ret, len, format, args2);
#else
- vsprintf(ret, format, args);
+ vsprintf(ret, format, args2);
#endif
if (pool != data_stack_pool)
t_pop();
More information about the dovecot-cvs
mailing list