From 7fea2dfcbd24adc56c91fb0fd6bfa8f75c5f2ebe Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Sat, 22 Jun 2019 13:22:59 -0700 Subject: [PATCH] Add fix for rhbz# 1645886. Thanks Oleg Samarin. --- chntpw-140201-fix-bogus-errno-use.patch | 34 +++++++++++++++++++++++++ chntpw.spec | 9 ++++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 chntpw-140201-fix-bogus-errno-use.patch diff --git a/chntpw-140201-fix-bogus-errno-use.patch b/chntpw-140201-fix-bogus-errno-use.patch new file mode 100644 index 0000000..ff7c846 --- /dev/null +++ b/chntpw-140201-fix-bogus-errno-use.patch @@ -0,0 +1,34 @@ +diff -u chntpw-140201.orig/ntreg.c chntpw-140201/ntreg.c +--- chntpw-140201.orig/ntreg.c 2019-06-22 13:09:59.583717369 -0700 ++++ chntpw-140201/ntreg.c 2019-06-22 13:16:26.714726148 -0700 +@@ -4241,10 +4241,13 @@ + do { /* On some platforms read may not block, and read in chunks. handle that */ + r = read(hdesc->filedesc, hdesc->buffer + rt, hdesc->size - rt); + rt += r; +- } while ( !errno && (rt < hdesc->size) ); ++ } while ( r > 0 && (rt < hdesc->size) ); + +- if (errno) { +- perror("openHive(): read error: "); ++ if (r <= 0) { ++ if (r < 0) ++ perror("openHive(): read error"); ++ else ++ fprintf(stderr, "openHive(): read error: unexpected EOF\n"); + closeHive(hdesc); + return(NULL); + } +@@ -4255,10 +4258,10 @@ + return(NULL); + } + +- if (r < sizeof (*hdesc)) { ++ if (rt < sizeof (*hdesc)) { + fprintf(stderr, +- "file is too small; got %d bytes while expecting %d or more\n", +- r, sizeof (*hdesc)); ++ "file is too small; got %d bytes while expecting %zu or more\n", ++ rt, sizeof (*hdesc)); + closeHive(hdesc); + return(NULL); + } diff --git a/chntpw.spec b/chntpw.spec index fd2d138..8016682 100644 --- a/chntpw.spec +++ b/chntpw.spec @@ -1,7 +1,7 @@ Name: chntpw # Version is taken from HISTORY.txt Version: 1.00 -Release: 3.140201%{?dist} +Release: 4.140201%{?dist} Summary: Change passwords in Windows SAM files License: GPLv2 URL: http://pogostick.net/~pnh/ntpasswd/ @@ -28,6 +28,9 @@ Patch5: chntpw-080526-correct-test-for-failing-open-syscall.patch Patch6: chntpw-110511-detect-failure-to-write-key.patch Patch7: chntpw-110511-reged-no-deref-null.patch +# Patch derived from Oleg Samarin (RHBZ#1645886) +Patch8: chntpw-140201-fix-bogus-errno-use.patch + %description This is a utility to (re)set the password of any user that has a valid @@ -53,6 +56,7 @@ mv WinReg.txt.eol WinReg.txt %patch5 -p1 %patch6 -p1 %patch7 -p1 +%patch8 -p1 %build @@ -82,6 +86,9 @@ cp -p %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} \ %changelog +* Sat Jun 22 2019 Conrad Meyer - 1.00-4.140201 +- Add fix for rhbz# 1645886. Thanks Oleg Samarin. + * Thu Jan 31 2019 Fedora Release Engineering - 1.00-3.140201 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild