xfs
[Top] [All Lists]

review: xfs_copy fix

To: xfs-dev@xxxxxxx
Subject: review: xfs_copy fix
From: Timothy Shimmin <tes@xxxxxxx>
Date: Fri, 06 Oct 2006 16:18:10 +1000
Cc: xfs@xxxxxxxxxxx
Sender: xfs-bounce@xxxxxxxxxxx
Request for review.

xfs_copy was seg faulting for me on my x86_64 box.
This fixes up the variable arg handling for multiple
vfprintf calls by putting va_start and va_end calls
around them (never done this before:).

Thanks,
--Tim


===========================================================================
Index: xfs-cmds/xfsprogs/copy/xfs_copy.c
===================================================================
--- xfs-cmds.orig/xfsprogs/copy/xfs_copy.c 2006-10-06 13:55:01.000000000 +1000
+++ xfs-cmds/xfsprogs/copy/xfs_copy.c   2006-10-06 13:52:14.000000000 +1000
@@ -77,17 +77,23 @@
        va_list ap;
        int     eek = 0;

-       va_start(ap, fmt);
-       if (flags & LOG)
+       if (flags & LOG) {
+               va_start(ap, fmt);
                if (vfprintf(logerr, fmt, ap) <= 0)
                        eek = 1;
+               va_end(ap);
+       }
        if (eek)
                flags |= ERR;   /* failed, force stderr */
-       if (flags & ERR)
+       if (flags & ERR) {
+               va_start(ap, fmt);
                vfprintf(stderr, fmt, ap);
-       else if (flags & OUT)
+               va_end(ap);
+       } else if (flags & OUT) {
+               va_start(ap, fmt);
                vfprintf(stdout, fmt, ap);
-       va_end(ap);
+               va_end(ap);
+       }

        if (flags & PRE) {
                do_message(flags & ~PRE, 0, ":  %s\n", strerror(code));


<Prev in Thread] Current Thread [Next in Thread>