pwsafe-0.2.0-cvs-1.57.patch 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. Index: pwsafe.cpp
  2. ===================================================================
  3. RCS file: /cvsroot/pwsafe/pwsafe/pwsafe.cpp,v
  4. retrieving revision 1.56
  5. retrieving revision 1.57
  6. diff -u -r1.56 -r1.57
  7. --- pwsafe.cpp 30 Sep 2005 10:30:56 -0000 1.56
  8. +++ pwsafe.cpp 12 Aug 2007 12:33:06 -0000 1.57
  9. @@ -3346,6 +3346,12 @@
  10. }
  11. bufpos += rc;
  12. + buf[bufpos] = '\0';
  13. +
  14. + if (rc == 0) {
  15. + // EOF (ctrl-D)
  16. + break;
  17. + }
  18. if (bufpos == buflen && !strchr(buf,'\n')) {
  19. // we needed a bigger buffer
  20. @@ -3354,6 +3360,7 @@
  21. fprintf(stderr, "Error: %s out of memory\n", program_name);
  22. memset(buf,0,buflen);
  23. free(buf);
  24. + throw FailEx();
  25. }
  26. memcpy(new_buf, buf, bufpos);
  27. @@ -3364,9 +3371,15 @@
  28. }
  29. }
  30. - int len = strchr(buf,'\n') - buf;
  31. - saved.assign(buf+len+1, bufpos-(len+1));
  32. - buf[len] = '\0';
  33. + char* lf = strchr(buf,'\n');
  34. + if (lf) {
  35. + // save the rest of the input for later
  36. + saved.assign(lf+1);
  37. + *lf = '\0';
  38. + } else {
  39. + saved.assign("",0);
  40. + }
  41. +
  42. return buf;
  43. }
  44. #endif // WITH_READLINE