[PATCH bpf-next v6 0/2] bpftool: fix batch file handling issues

Yuan Chen <[email protected]>
Newsgroups org.kernel.vger.bpf
Message-ID <[email protected]>
This series fixes two remaining issues in bpftool's batch file handling
(the double-close fix from v5 has been applied upstream and is no
longer part of this series):

 1. do_batch() reports a spurious read failure because a stale errno
    left by a previously executed command is checked after the read
    loop instead of the outcome of the last fgets() call.
 2. a line longer than the batch buffer that contains a '#' within the
    buffered prefix bypasses the line length check: the comment
    stripping truncates the buffer before the length is checked, so the
    unread remainder of the line is parsed and executed as a separate
    command on the next loop iteration. Continuation lines are affected
    the same way, bypassing the "command is too long" check.

Many thanks to Andrii Nakryiko for the review: patch 1 now clears errno
before each fgets() call instead of tracking the too-long-line case
with an explicit flag, and patch 2 moves the line-length checks before
the comment stripping instead of detecting truncated reads with
memchr()/feof().

Changes in v6:
  - drop the double-close patch, which has been applied upstream; the
    series is now two patches
  - "fix spurious batch file read error": clear errno before each
    fgets() call, and drop the explicit line_too_long flag and the
    ferror() check (reviewer feedback)
  - "Fix bypass of the batch line length check by comments": move the
    line-length checks before the comment stripping, dropping the
    memchr()/feof() truncation detection (reviewer feedback)

Yuan Chen (2):
  bpftool: fix spurious batch file read error
  bpftool: Fix bypass of the batch line length check by comments

 tools/bpf/bpftool/main.c | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.