Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sun, 11 Jun 2017 18:31:17 +0000
From: Pascal Cuoq <cuoq@...st-in-soft.com>
To: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: redefinition of variable index in musl 1.1.16?

Hello,

this message may describe a minor compilation issue on some platforms. Let me apologize right here if this is only caused by me messing up the defines.

Consider the file made of these two lines:

char *index (const char *, int);

static const unsigned char *index;

The above is an incorrect C program, as confirmed by GCC and Clang:

$ clang t.c
t.c:3:29: error: redefinition of 'index' as different kind of symbol
...
$ gcc t.c
t.c:3:29: error: 'index' redeclared as different kind of symbol
...

It seems to me that musl's src/time/__tz.c may be an extended version of the same two-line program in some circumstances, through the following route:

- __tz.c includes string.h

- in some circumstances string.h includes strings.h:
#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
#include <strings.h>
#endif

- strings.h may define a function “index”:
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
int bcmp (const void *, const void *, size_t);
void bcopy (const void *, void *, size_t);
void bzero (void *, size_t);
char *index (const char *, int);
char *rindex (const char *, int);
#endif

- __tz.c defines a static pointer to const unsigned char index at line 23.

Again I apologize for the waste of time if this is not something that can happen for people who compile musl normally. If it can happen, it can be fixed simply by choosing a name other than “index” for the variable that is static to __tz.c.

Pascal

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.