Page MenuHomeFreeBSD

libbsdconf: parse from a bounded in-memory buffer
Needs ReviewPublic

Authored by dteske on Thu, Sep 17, 12:59 AM.

Details

Reviewers
fuz
kfv
Summary

Copy the descriptor into a buffer of at most 64 MiB (raise it with
BSDCONF_MAX_BYTES) and tokenize with bsdconf_scan(), the walker
bsdconf_put() already uses. Input above the cap fails with EFBIG.
Bump libbsdconf to 2.0.0 and sysconf(8) to 2.0.

Suggested by: fuz

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 77009
Build 73892: arc lint + arc unit

Event Timeline

lib/libbsdconf/bsdconf.h
40

Assuming we use semantic versioning here, what is the API break that requires a major version update?

lib/libbsdconf/bsdconf_stmt.c
196

This potentially stomps over the errno value reported by read.

206

There are some theoretical reasons why growing the cap by the golden ration (approx. 13/8) is better, but doubling the size is certainly workable.

207

This makes the intent easier to understand.
Or use ckd_mul from <stdckdint.h> to check for overflow (requires C23).