View Issue Details

IDProjectCategoryView StatusLast Update
0000269file[All Projects] Generalpublic2021-06-30 10:12
ReporterroneythAssigned Tochristos 
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in VersionHEAD 
Summary0000269: Undefined Behavior: applying zero offset to null pointer
DescriptionEnabling Undefined Behavior Sanitizer (UBSAN) check for pointer overflow(-fsanitize=pointer-overflow) causes the below error to be detected in file/src/apprentice.c.

/src/apprentice.c:567:43: runtime error: applying zero offset to null pointer
    #0 0x7f9c571ef541 in apprentice_unmap src/apprentice.c:567:43
    0000001 0x7f9c571ef34b in mlist_free_one src/apprentice.c:611:3
    0000002 0x7f9c571ed261 in mlist_free src/apprentice.c:625:3
    0000003 0x7f9c571ed147 in file_ms_free src/apprentice.c:504:3
    0000004 0x7f9c572172ae in magic_close src/magic.c:291:2
    0000005 0x2f16d5 in main tests/test.c
    0000006 0x7f9c56008674 in __libc_start_main libc-start.c
    0000007 0x24aeb8 in _start elfstart.S

The code where error observed
                CAST(char *, b) <= CAST(char *, p) + map->len)

Steps To Reproduceclang++ -fsanitize=pointer-overflow sourcefile
Additional InformationFWIW. we have thought of a fix as :
CAST(char *, b) <= (p ? CAST(char *, p) + map->len : CAST(char *, map->len)))
I wonder if there isn't a more elegant solution . Please do check the issue and make a fix ASAP.
TagsNo tags attached.



2021-06-30 10:12

manager   ~0003616

Fixed, thanks.

Issue History

Date Modified Username Field Change
2021-06-07 16:40 roneyth New Issue
2021-06-30 10:12 christos Assigned To => christos
2021-06-30 10:12 christos Status new => assigned
2021-06-30 10:12 christos Status assigned => resolved
2021-06-30 10:12 christos Resolution open => fixed
2021-06-30 10:12 christos Fixed in Version => HEAD
2021-06-30 10:12 christos Note Added: 0003616