Package: chntpw Version: 1.0-1 Severity: important Tags: upstream patch chntpw fails to read files from read-only filesystems, despite having some logic to handle this:
# chntpw -e /c/Windows/System32/config/SOFTWARE chntpw version 1.00 140201, (c) Petter N Hagen openHive(/c/Windows/System32/config/SOFTWARE) failed: Read-only file system, trying read-only openHive(): read error: : Read-only file system chntpw: Unable to open/read a hive, exiting.. # This is due to using errno as an error checking mechanism; it should only be used when one knows a function has failed. The attached patch fixes this problem. It also adds support for the non-fatal EINTR error, and fixes yet another bug where the last read size is used in a check instead of the whole file size. Cheers, -- Sam. -- System Information: Debian Release: jessie/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (500, 'oldstable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.16-trunk-amd64 (SMP w/4 CPU cores) Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages chntpw depends on: ii libc6 2.19-11 ii libgcrypt11 1.5.4-3 chntpw recommends no packages. chntpw suggests no packages. -- no debconf information
Index: chntpw-1.0/ntreg.c =================================================================== --- chntpw-1.0.orig/ntreg.c +++ chntpw-1.0/ntreg.c @@ -4241,9 +4241,9 @@ struct hive *openHive(char *filename, in 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 || (r < 0 && errno == EINTR)) && (rt < hdesc->size) ); - if (errno) { + if (r < 0) { perror("openHive(): read error: "); closeHive(hdesc); return(NULL); @@ -4255,10 +4255,10 @@ struct hive *openHive(char *filename, in 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)); + rt, sizeof (*hdesc)); closeHive(hdesc); return(NULL); }