From jim@meyering.net Mon Jul 20 20:12:31 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:12:31 +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:12:17 -0400 (EDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by zmta03.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 3C1A04E4EC for ; Mon, 20 Jul 2009 15:12:17 -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 a+PpYwgPRjqW for ; Mon, 20 Jul 2009 15:12:17 -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 130A44E4D6 for ; Mon, 20 Jul 2009 15:12:17 -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 n6KJCGMZ001977 for ; Mon, 20 Jul 2009 15:12:16 -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 n6KJCF82022169 for ; Mon, 20 Jul 2009 15:12:15 -0400 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 36C5D38154; Mon, 20 Jul 2009 21:12:15 +0200 (CEST) From: Jim Meyering To: "Richard W. M. Jones" Subject: chntpw [PATCH] detect/diagnose failure to write key Date: Mon, 20 Jul 2009 21:12:15 +0200 Message-ID: <873a8r88z4.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: 938 Lines: 34 Hi Rich, here's another. >From 057c832cf924cabf887e59d1c1f2127cd4619572 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 20 Jul 2009 15:09:26 -0400 Subject: [PATCH] detect/diagnose failure to write key * ntreg.c (export_key): Detect stream write failure. --- ntreg.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/ntreg.c b/ntreg.c index 21cd3e3..cdb6503 100644 --- a/ntreg.c +++ b/ntreg.c @@ -2735,7 +2735,14 @@ void export_key(struct hive *hdesc, int nkofs, char *name, char *filename, char fprintf(file, "Windows Registry Editor Version 5.00\r\n\r\n"); export_subkey(hdesc, nkofs, name, prefix, file); - fclose(file); + if (ferror (file)) { + printf("failed to write file '%s'\n", filename); + fclose (file); + return; + } + if (fclose(file)) + printf("failed to write file '%s': %s\n", filename, + strerror(errno)); } -- 1.6.2.5