Sophie

Sophie

distrib > Mageia > 8 > aarch64 > by-pkgid > 77ea68a930337ddaa524a84012be201c > files > 4

chntpw-1.0-5.mga8.src.rpm


The first two were spotted via inspection by Fedora team,
the third one was added to address an error found using valgrind:
   $ : > j && valgrind ./reged -e j
       ~/w/co/chntpw: 
  ==16084==    by 0x4011E3: main (reged.c:103)
     get_abs_path: Not a 'nk' node!

* ntreg.c (fmyinput): Don't clobber ibuf[-1] upon NUL input.
* ntreg.c (convert_string): Don't segfault upon low memory.
* ntreg.c (openHive): Don't read uninitialized when file is too small.
--- a/ntreg.c
+++ b/ntreg.c
@@ -227,14 +227,18 @@
 
 int fmyinput(char *prmpt, char *ibuf, int maxlen)
 {
-   
+   int len;
    printf("%s",prmpt);
    
    fgets(ibuf,maxlen+1,stdin);
+   len = strlen(ibuf);
    
-   ibuf[strlen(ibuf)-1] = 0;
-   
-   return(strlen(ibuf));
+   if (len) {
+      ibuf[len-1] = 0;
+      --len;
+    }
+
+   return len;
 }
 
 /* Print len number of hexbytes */
@@ -4250,6 +4254,14 @@
     closeHive(hdesc);
     return(NULL);
   }
+
+  if (r < sizeof (*hdesc)) {
+    fprintf(stderr,
+	    "file is too small; got %d bytes while expecting %d or more\n",
+	    r, sizeof (*hdesc));
+    closeHive(hdesc);
+    return(NULL);
+  }
 
   /* Now run through file, tallying all pages */
   /* NOTE/KLUDGE: Assume first page starts at offset 0x1000 */