chntpw-110511-robustness.patch 875 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --- chntpw-110511.orig/ntreg.c 2011-05-11 12:33:56.000000000 -0700
  2. +++ chntpw-110511/ntreg.c 2011-12-18 17:09:06.290818997 -0800
  3. @@ -190,14 +190,18 @@
  4. int fmyinput(char *prmpt, char *ibuf, int maxlen)
  5. {
  6. -
  7. + int len;
  8. printf("%s",prmpt);
  9. fgets(ibuf,maxlen+1,stdin);
  10. + len = strlen(ibuf);
  11. - ibuf[strlen(ibuf)-1] = 0;
  12. + if (len) {
  13. + ibuf[len-1] = 0;
  14. + --len;
  15. + }
  16. - return(strlen(ibuf));
  17. + return len;
  18. }
  19. /* Print len number of hexbytes */
  20. @@ -4119,6 +4123,14 @@
  21. closeHive(hdesc);
  22. return(NULL);
  23. }
  24. +
  25. + if (r < sizeof (*hdesc)) {
  26. + fprintf(stderr,
  27. + "file is too small; got %d bytes while expecting %d or more\n",
  28. + r, sizeof (*hdesc));
  29. + closeHive(hdesc);
  30. + return(NULL);
  31. + }
  32. /* Now run through file, tallying all pages */
  33. /* NOTE/KLUDGE: Assume first page starts at offset 0x1000 */