Skip to content

UBSan runtime error:void libconfig_format_bin(int64_t val, char *buf, size_t buflen) #268

Open
@Wowblk

Description

@Wowblk

My fuzzer discovered two UBSan runtime error,however, I’ve found that triggering these two bugs is fairly complex and I haven’t yet been able to produce a minimal reproducible example. However, I do have the call stacks and a rough idea of the CFG structure. When calling cfg.write(), it dives into the libconfig write routines—specifically libconfig_format_bin—and within that function two UBSan errors occur at lines 309 and 314, respectively. These errors never fire together: in most cases, once the “UBSan: passing zero to clz(), which is not a valid argument” error occurs, the second error never happens. Below I’ll provide the two error call stacks and the CFG input that triggered them.

By the way, the source code about the cfg.write part in my fuzzer is:

   if (devnull) {
        try {
            cfg.write(devnull);
        }
        catch (const libconfig::FileIOException&) {} 
        catch (...) {} 
    }

The first one:UBSan:passing zero to clz(), which is not a valid argument
=== Config Debug Info ===
Root has 5 children:
K [Int]: 2
B10 [Int]: 1
B [Int]: 3
C [Int]: 0
fuzz_group [Group] (1 children)
inner_list [List] (1 items)
(unnamed) [String]: "hif"
=== End Config Debug Info ===

Image

The second one:UBSan:left shift of 1 by 63 places cannot be represented in type ‘long long’
=== Config Debug Info ===
Root has 3 children:
K [Int64]: -131074
C [Int]: 1
fuzz_group [Group] (1 children)
inner_list [List] (1 items)
(unnamed) [String]: "hif"
=== End Config Debug Info ===

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions