From 75cac1c93b6dd0b22a855559100c0cbfa928d6e9 Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Mon, 30 Sep 2024 15:19:53 +0200 Subject: [PATCH] fix issue when receiving partial lines --- snmpd-oid-daemon.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/snmpd-oid-daemon.sh b/snmpd-oid-daemon.sh index daf8b0e..90f65f5 100755 --- a/snmpd-oid-daemon.sh +++ b/snmpd-oid-daemon.sh @@ -463,15 +463,13 @@ function main() { # received complete line from stdin line=$buf elif (( rc > 128 )); then - # read timed out, check for partial data - if [ -n "$buf" ]; then - echo "< $buf (partial line)" >&$DEBUGLOG - line=$buf - # read the rest of the line - read -r -u $STDIN buf || exit 255 - line+=$buf - fi - continue + # read timed out, continue if no partial data received + [ -z "$buf" ] && continue + echo "< $buf (partial line)" >&$DEBUGLOG + line=$buf + # read the rest of the line + read -r -u $STDIN buf || exit 255 + line+=$buf else exit 255 fi