From: oech3 <79379754+oech3@users.noreply.github.com> Date: Wed, 1 Apr 2026 11:37:09 +0000 (+0900) Subject: tests: dd: ensure memory exhaustion is handled gracefully X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3558839bdd3ca37e80d5140ce7296c71b98b3db0;p=thirdparty%2Fcoreutils.git tests: dd: ensure memory exhaustion is handled gracefully * tests/dd/no-allocate.sh: Ensure we exit 1 upon mem allocation failure. Also check other buffer size edge cases. https://github.com/uutils/coreutils/issues/11436 https://github.com/uutils/coreutils/issues/11580 https://github.com/coreutils/coreutils/pull/235 --- diff --git a/tests/dd/no-allocate.sh b/tests/dd/no-allocate.sh index 76726a1709..f5ed903fcc 100755 --- a/tests/dd/no-allocate.sh +++ b/tests/dd/no-allocate.sh @@ -25,6 +25,16 @@ vm=$(get_min_ulimit_v_ timeout 10 dd if=f of=f2 status=none) \ || skip_ 'shell lacks ulimit, or ASAN enabled' rm f f2 || framework_failure_ +# Ensure dd exits with 1 if memory exhausted +(ulimit -v $vm && returns_ 1 \ + dd if=/dev/null of=/dev/null bs=$(($SSIZE_MAX-1))) || fail=1 +# Ensure dd exits with 1 on numeric overflow +(ulimit -v $vm && returns_ 1 \ + dd if=/dev/null of=/dev/null bs=$SIZE_OFLOW) || fail=1 +# Ensure dd exits with 1 on invalid number +(ulimit -v $vm && returns_ 1 \ + dd if=/dev/null of=/dev/null bs=0) || fail=1 + # count and skip are zero, we don't need to allocate memory (ulimit -v $vm && dd bs=30M count=0) || fail=1 (ulimit -v $vm && dd ibs=30M count=0) || fail=1