Source-Changes-HG archive

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

[src/trunk]: src/lib/libisns Fix up mangled logic, hopefully. PR 54323 from D...



details:   https://anonhg.NetBSD.org/src/rev/dae09842917f
branches:  trunk
changeset: 1000063:dae09842917f
user:      dholland <dholland%NetBSD.org@localhost>
date:      Wed Jul 03 18:40:33 2019 +0000

description:
Fix up mangled logic, hopefully. PR 54323 from David Binderman.

XXX: This code is pretty dodgy in general and would benefit from a
XXX: workover by someone who knows what it's supposed to be doing.
XXX: E.g. it appears that a read error will cause an infinite loop...

diffstat:

 lib/libisns/isns_thread.c |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diffs (39 lines):

diff -r c591fd085948 -r dae09842917f lib/libisns/isns_thread.c
--- a/lib/libisns/isns_thread.c Wed Jul 03 18:24:50 2019 +0000
+++ b/lib/libisns/isns_thread.c Wed Jul 03 18:40:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isns_thread.c,v 1.1.1.1 2011/01/16 01:22:50 agc Exp $  */
+/*     $NetBSD: isns_thread.c,v 1.2 2019/07/03 18:40:33 dholland Exp $ */
 
 /*-
  * Copyright (c) 2004,2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: isns_thread.c,v 1.1.1.1 2011/01/16 01:22:50 agc Exp $");
+__RCSID("$NetBSD: isns_thread.c,v 1.2 2019/07/03 18:40:33 dholland Exp $");
 
 
 /*
@@ -152,12 +152,16 @@
                        DBG("isns_kevent_pipe: ISNS_CMD_ABORT_TRANS\n");
                        rbytes = read(cfg_p->pipe_fds[0], &trans_id,
                            sizeof(trans_id));
-                       if ((rbytes < 0) && (rbytes == sizeof(trans_id)))
-                               isns_abort_trans(cfg_p, trans_id);
-                       else
+                       if (rbytes < 0)
                                DBG("isns_kevent_pipe: "
                                    "error reading trans id\n");
-                       pipe_nbytes -= (int)rbytes;
+                       else if (rbytes != sizeof(trans_id))
+                               DBG("isns_kevent_pipe: "
+                                   "short read reading trans id\n");
+                       else {
+                               isns_abort_trans(cfg_p, trans_id);
+                               pipe_nbytes -= (int)rbytes;
+                       }
                        break;
 
                case ISNS_CMD_STOP:



Home | Main Index | Thread Index | Old Index