diff options
Diffstat (limited to 'misc/chntpw/patches/chntpw-140201-fix-bogus-errno-use.patch')
-rw-r--r-- | misc/chntpw/patches/chntpw-140201-fix-bogus-errno-use.patch | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/misc/chntpw/patches/chntpw-140201-fix-bogus-errno-use.patch b/misc/chntpw/patches/chntpw-140201-fix-bogus-errno-use.patch new file mode 100644 index 0000000000..ff7c8467b7 --- /dev/null +++ b/misc/chntpw/patches/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); + } |