From jim@meyering.net Mon Jul 20 20:05:55 2009 Return-Path: jim@meyering.net X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on amd.home.annexia.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.2.5 Received: from mail.corp.redhat.com [10.5.5.51] by amd.home.annexia.org with IMAP (fetchmail-6.3.8) for (single-drop); Mon, 20 Jul 2009 20:05:55 +0100 (BST) Received: from zmta03.collab.prod.int.phx2.redhat.com (LHLO zmta03.collab.prod.int.phx2.redhat.com) (10.5.5.33) by mail06.corp.redhat.com with LMTP; Mon, 20 Jul 2009 15:05:47 -0400 (EDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by zmta03.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 2C1134E4EB for ; Mon, 20 Jul 2009 15:05:47 -0400 (EDT) Received: from zmta03.collab.prod.int.phx2.redhat.com ([127.0.0.1]) by localhost (zmta03.collab.prod.int.phx2.redhat.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id a7N9dvNRkYQB for ; Mon, 20 Jul 2009 15:05:47 -0400 (EDT) Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by zmta03.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 034384E4D6 for ; Mon, 20 Jul 2009 15:05:46 -0400 (EDT) Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6KJ5kIt032703 for ; Mon, 20 Jul 2009 15:05:46 -0400 Received: from mx.meyering.net (sebastian-int.corp.redhat.com [172.16.52.221]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6KJ5jf3021050 for ; Mon, 20 Jul 2009 15:05:45 -0400 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id D674638154; Mon, 20 Jul 2009 21:05:44 +0200 (CEST) From: Jim Meyering To: "Richard W. M. Jones" Subject: chntpw [PATCH] correct test for failing "open" syscall Date: Mon, 20 Jul 2009 21:05:44 +0200 Message-ID: <878wij899z.fsf@meyering.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Status: RO Content-Length: 1103 Lines: 33 This one is weird. It must be code that is never exercised, since the existing code is totally bogus. The condition, !open(...), will almost always be true. (sole exception is when starting a program with stdin initially closed) >From bc4cddb06cf13c189fbdc93e6962cad072779097 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 20 Jul 2009 14:59:19 -0400 Subject: [PATCH] correct test for failing "open" syscall * ntreg.c (writeHive): Test open() < 0, not !open(). --- ntreg.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/ntreg.c b/ntreg.c index be6b680..21cd3e3 100644 --- a/ntreg.c +++ b/ntreg.c @@ -2765,7 +2765,7 @@ int writeHive(struct hive *hdesc) if ( !(hdesc->state & HMODE_DIRTY)) return(0); if ( !(hdesc->state & HMODE_OPEN)) { /* File has been closed */ - if (!(hdesc->filedesc = open(hdesc->filename,O_RDWR))) { + if ((hdesc->filedesc = open(hdesc->filename,O_RDWR)) < 0) { fprintf(stderr,"writeHive: open(%s) failed: %s, FILE NOT WRITTEN!\n",hdesc->filename,strerror(errno)); return(1); } -- 1.6.2.5