View Issue Details

IDProjectCategoryView StatusLast Update
0000409fileGeneralpublic2023-01-08 16:50
ReporterGirgias Assigned Tochristos  
PrioritynormalSeverityblockReproducibilityalways
Status assignedResolutionopen 
PlatformLinuxOSCentOS (Core) OS Version7.9.2009
Product Version5.43 
Summary0000409: Compilation error in softmagic.c due to redefining strndup in AIX preprocessor block
DescriptionThis was first reported to PHP here: https://github.com/php/php-src/pull/10074

The issue is located between lines 503 and 523 (https://github.com/file/file/blob/master/src/softmagic.c#L503-L523)
Where the redeclaration of strndup probably should have been in an else block as otherwise the following compile errors can arise (line numbers inaccurate as it is the patched PHP version to use the PHP memory allocator):

/www/server/source/php/php82/ext/fileinfo/libmagic/softmagic.c:507:7: error: expected identifier or ‘(’ before ‘extension’
char *strndup(const char *, size_t);
^
/www/server/source/php/php82/ext/fileinfo/libmagic/softmagic.c:510:1: error: expected identifier or ‘(’ before ‘extension’
strndup(const char *str, size_t n)
^
make: *** [libmagic/softmagic.lo] Error 1
make: *** [libmagic/softmagic.lo] Error 1
TagsNo tags attached.

Activities

christos

2022-12-26 19:23

manager   ~0003878

can you provide the preprocessor output cc -E of those lines?

Girgias

2023-01-02 15:54

reporter   ~0003883

I've just asked the end-user if they can provide this information.

Girgias

2023-01-08 15:49

reporter   ~0003884

End user came back with this:

    gcc -E ext/fileinfo/libmagic/softmagic.c

[root@VM-EtsmUAZgUPAH php82]# gcc -E ext/fileinfo/libmagic/softmagic.c
# 1 "ext/fileinfo/libmagic/softmagic.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "ext/fileinfo/libmagic/softmagic.c"
# 32 "ext/fileinfo/libmagic/softmagic.c"
# 1 "ext/fileinfo/libmagic/file.h" 1
# 36 "ext/fileinfo/libmagic/file.h"
# 1 "ext/fileinfo/libmagic/config.h" 1
In file included from ext/fileinfo/libmagic/file.h:36:0,
                 from ext/fileinfo/libmagic/softmagic.c:32:
ext/fileinfo/libmagic/config.h:1:17: fatal error: php.h: No such file or directory
 #include "php.h"
                 ^
compilation terminated.

    Compile time error

libmagic/softmagic.dep -MT libmagic/softmagic.lo -fPIC -DPIC -o libmagic/.libs/softmagic.o
In file included from /usr/include/string.h:633:0,
                 from /www/server/php/82/include/php/main/../main/php_config.h:2207,
                 from /www/server/php/82/include/php/Zend/zend_config.h:1,
                 from /www/server/php/82/include/php/Zend/zend_portability.h:43,
                 from /www/server/php/82/include/php/Zend/zend_types.h:25,
                 from /www/server/php/82/include/php/Zend/zend.h:27,
                 from /www/server/php/82/include/php/main/php.h:31,
                 from /www/server/source/php/php82/ext/fileinfo/libmagic/config.h:1,
                 from /www/server/source/php/php82/ext/fileinfo/libmagic/file.h:36,
                 from /www/server/source/php/php82/ext/fileinfo/libmagic/softmagic.c:32:
/www/server/source/php/php82/ext/fileinfo/libmagic/softmagic.c:507:7: error: expected identifier or ‘(’ before ‘__extension__’
 char *strndup(const char *, size_t);
       ^
/www/server/source/php/php82/ext/fileinfo/libmagic/softmagic.c:510:1: error: expected identifier or ‘(’ before ‘__extension__’
 strndup(const char *str, size_t n)
 ^
make: *** [libmagic/softmagic.lo] Error 1

Hopefully this is the requested information, and apologies for the delay.

christos

2023-01-08 16:50

manager   ~0003885

Unfortunately not, since the compilation terminated early because the user did not supply the correct -I path where php.h lives.

Issue History

Date Modified Username Field Change
2022-12-12 16:37 Girgias New Issue
2022-12-26 19:22 christos Assigned To => christos
2022-12-26 19:22 christos Status new => assigned
2022-12-26 19:23 christos Status assigned => feedback
2022-12-26 19:23 christos Note Added: 0003878
2023-01-02 15:54 Girgias Note Added: 0003883
2023-01-02 15:54 Girgias Status feedback => assigned
2023-01-08 15:49 Girgias Note Added: 0003884
2023-01-08 16:50 christos Note Added: 0003885