diff options
| author | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2026-06-06 13:44:00 -0400 |
|---|---|---|
| committer | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2026-06-06 13:44:00 -0400 |
| commit | c102ab995f9a86a77e40b9a952b2b23c0bd7de74 (patch) | |
| tree | d51b9a8f1a55f7f6e6e5afb89d524b9baa350f45 /bib-extract | |
| parent | b56c273d8198ae6cee69bbc9fe5a6a61da4074e4 (diff) | |
| download | bibutils-c102ab995f9a86a77e40b9a952b2b23c0bd7de74.tar.gz | |
Fuzzing with associated fixes
Diffstat (limited to 'bib-extract')
| -rwxr-xr-x | bib-extract | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/bib-extract b/bib-extract index 297588a..ac0363d 100755 --- a/bib-extract +++ b/bib-extract @@ -23,7 +23,10 @@ aux=$1 shift [ -r "$aux" ] || { printf 'bib-extract: cannot read %s\n' "$aux" >&2; exit 1; } -keys=$(awk ' +keyfile=$(mktemp) || exit 1 +trap 'rm -f "$keyfile"' EXIT INT TERM + +awk ' # classic bibtex: \citation{key,key,...} { line = $0 @@ -46,10 +49,10 @@ keys=$(awk ' print s line = substr(line, RSTART + RLENGTH) } - }' "$aux" | sort -u | paste -sd, -) + }' "$aux" | sort -u > "$keyfile" -[ -n "$keys" ] || exit 0 +[ -s "$keyfile" ] || exit 0 # a key of "*" (from \nocite{*}) selects the whole database -exec awk -f "$LIB/bib-parse.awk" -f "$LIB/bib-canon.awk" \ - -f "$LIB/bib-select.awk" -v keys="$keys" -v invert=0 "$@" +awk -f "$LIB/bib-parse.awk" -f "$LIB/bib-canon.awk" \ + -f "$LIB/bib-select.awk" -v keyfile="$keyfile" -v invert=0 "$@" |