[Bug c/34710] New: FORTIFY_SOURCE matches to many patterns

stefan dot bruens at rwth-aachen dot de gcc-bugzilla@gcc.gnu.org
Tue Jan 8 02:42:00 GMT 2008


The following is a short code fragment similar to code to be found in the open
source Argyll CMS (http://www.argyllcms.com/)
---
#include <stdio.h>

struct _iFile {
        int (*fprintf)(struct _iFile *p, const char *format, ...);
};

typedef struct _iFile iFile;

static int testprint(iFile *p, const char *format, ...) { };

int main(int argc, char* argv[]) {
        iFile p;

        p.fprintf = testprint;
        p.fprintf(&p, "%i", 123);
}
-----
gcc -D_FORTIFY_SOURCE=2 -O2  test.c -E | tail
-----
typedef struct _iFile iFile;

static int testprint(iFile *p, const char *format, ...) { };

int main(int argc, char* argv[]) {
 iFile p;

 p.fprintf = testprint;
 p.__fprintf_chk (&p, 2 - 1, "%i", 123);
}
-----
The second to last line is clearly wrong (or at least unintended)


-- 
           Summary: FORTIFY_SOURCE matches to many patterns
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: stefan dot bruens at rwth-aachen dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34710



More information about the Gcc-bugs mailing list