blob: ff7c8467b721bde5fcb1e55e0abef2f4b6e5cacf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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);
}
|