found 326864 0.5-1
tags 326864 + patch
thanks

Hi,

fl-cow is failing to build on atleast amd64 with a segmentation
fault.  The problem is that it's not using the proper prototype
for the open() function.

The problem is that it the implementation of stdarg (...) is not
the same on all arches, which makes it work on some and fail on
others.  (This is also the reason va_copy() exists.)  And then
you have to mix the size of pointers with that.

I've attached that patch that fixes it, and atleast allow it to
pass the test suite on amd64.


Kurt

--- ./fl-cow/fl-cow.c.old       2005-10-19 20:00:42.502236080 +0200
+++ ./fl-cow/fl-cow.c   2005-10-19 20:20:02.188344288 +0200
@@ -61,11 +61,11 @@
 #define FLCOW_ALIAS(asym, rsym) int asym(const char *, int, ...) __attribute__ 
((weak, alias("flcow_" #rsym)))
 #define FLCOW_MAPFUNC(sym) \
        int flcow_##sym(const char *name, int flags, ...) { \
-               static int (*func_open)(const char *, int, mode_t) = NULL; \
+               static int (*func_open)(const char *, int, ...) = NULL; \
                va_list args; \
                mode_t mode; \
                if (!func_open && \
-                           !(func_open = (int (*)(const char *, int, mode_t)) \
+                           !(func_open = (int (*)(const char *, int, ...)) \
                                      dlsym(REAL_LIBC, #sym))) { \
                        fprintf(stderr, "missing symbol: %s\n", #sym); \
                        exit(1); \
@@ -120,7 +120,7 @@
 }
 
 
-static int do_cow_name(const char *name, int (*open_proc)(const char *, int, 
mode_t)) {
+static int do_cow_name(const char *name, int (*open_proc)(const char *, int, 
...)) {
        int nfd, sfd;
        void *addr;
        struct stat stb;
@@ -168,7 +168,7 @@
 
 
 static int do_generic_open(const char *name, int flags, mode_t mode,
-                          int (*open_proc)(const char *, int, mode_t)) {
+                          int (*open_proc)(const char *, int, ...)) {
        struct stat stb;
 
        if ((flags & O_RDWR || flags & O_WRONLY) && cow_name(name) &&

Reply via email to