Add fix for rhbz# 1645886. Thanks Oleg Samarin.

This commit is contained in:
Conrad Meyer 2019-06-22 13:22:59 -07:00
commit 7fea2dfcbd
2 changed files with 42 additions and 1 deletions

View file

@ -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);
}

View file

@ -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 <cemeyer@uw.edu> - 1.00-4.140201
- Add fix for rhbz# 1645886. Thanks Oleg Samarin.
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.00-3.140201
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild