]> git.ipfire.org Git - thirdparty/systemd.git/commit
udev-rules: drop truncated import output line
authordongshengyuan <545258830@qq.com>
Fri, 10 Jul 2026 08:05:24 +0000 (16:05 +0800)
committerdongshengyuan <545258830@qq.com>
Fri, 10 Jul 2026 08:05:24 +0000 (16:05 +0800)
commit9095da896fc1bdd86b5b749d71bd2aebc585e236
tree095eee8608df9a3dbbde58d010f5e35366ec20db
parent13d8955088c00ca87619a146a1a85c3f67e4211d
udev-rules: drop truncated import output line

When IMPORT{program} output was truncated, the code intended to drop
the last incomplete result line before importing properties.

It edited the command buffer instead of the output buffer, so the
incomplete line could still be parsed and imported.

Trim the result buffer and cover the behavior with the existing IMPORT
test.

Follow-up for 6b6e471a325bf149839c5c822b4ae3e66cb1d9a3.

Reproducer:

Configure an IMPORT{program} rule whose output exceeds UDEV_LINE_SIZE
and ends with an incomplete property line, for example:

TRUNCATED_OK=yes
TRUNCATED_BAD=<very long value without terminating newline>

Only TRUNCATED_OK should be imported. Before this fix, the truncation
handler edited the command buffer instead of the output buffer, so
TRUNCATED_BAD could still be parsed from the truncated result.
src/udev/udev-rules.c
test/units/TEST-17-UDEV.IMPORT.sh