From aaba23a7f450d43d0062d66a712e5d0de62f7e87 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 6 Nov 2013 10:37:42 +0100 Subject: term: fix error handling in hurdio_mdmctl hurdio_mdmctl allows one to set and clear bits from the modem control bit vector. However, plausible code paths exist that leave oldbits uninitialized. Fix this by returning an error instead if retrieving the oldbits failed and the bit set or clear operation was selected. Found using the Clang Static Analyzer. * term/hurdio.c (hurdio_mdmctl): Fix error handling. --- term/hurdio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'term/hurdio.c') diff --git a/term/hurdio.c b/term/hurdio.c index 357ab383..b34854cd 100644 --- a/term/hurdio.c +++ b/term/hurdio.c @@ -585,10 +585,15 @@ hurdio_mdmctl (int how, int bits) { error_t err = tioctl_tiocmodg (ioport, &oldbits); if (err && (err == EMIG_BAD_ID || err == EOPNOTSUPP)) - tioc_caps &= ~TIOC_CAP_MODG; + { + tioc_caps &= ~TIOC_CAP_MODG; + return EOPNOTSUPP; + } else if (err) return err; } + else + return EOPNOTSUPP; } if (how == MDMCTL_BIS) -- cgit v1.2.3