slackbuilds_ponce/misc/chntpw/patches/chntpw-140201-fix-bogus-errno-use.patch
Matteo Bernardini 11004b0d10 misc/chntpw: Updated for version 140201.
Use libgcrypt instead of openssl, don't build static binaries

Signed-off-by: Matteo Bernardini <ponce@slackbuilds.org>
2021-04-17 23:15:55 -05:00

34 lines
1.1 KiB
Diff

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