coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] stty: give explicit error for unsupported asymmetric speeds


From: Pádraig Brady
Subject: [PATCH] stty: give explicit error for unsupported asymmetric speeds
Date: Sun, 11 Sep 2022 18:49:50 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:98.0) Gecko/20100101 Thunderbird/98.0

On 11/09/2022 15:47, Pádraig Brady wrote:
On 31/08/2022 00:22, Pádraig Brady wrote:
* src/stty.c (apply_settings): Validate [io]speed arguments
against the internal accepted set.
(set_speed): Check the cfset[io]speed() return value so
that we validate against the system supported set.

When testing this I noticed that errors would be
printed on Linux on the first change of [io]speed,
but not on subsequent invocations.

I added the ---debug option to help investigate the
difference between returned and expected mode bits.

That led me to the conclusion that using memcmp()
across the whole mode structure is a layering violation,
which was already seen to fail on Solaris when setting speeds,
and seen to fail on Linux also.

Instead the attached patch uses documented interfaces
(already used anyway in stty), to inspect the returned mode.
This also simplifies the code as we don't need to
handle edge cases.

This was independently identified as an issue in
https://bugs.debian.org/1019468

With the above the following now doesn't fail:
  stty ispeed 1000000

However the following should fail when not supported
(as is the case on Linux):
  stty ispeed 1000000 ospeed 4000000

The attached implements that validation.

cheers,
Pádraig

Attachment: stty-asym-iospeed-error.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]