[Qt] Terminate string *pszExePath after readlink and without using memset #11193

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:null-terminate-after-readlink changing 1 files +3 −2
  1. practicalswift commented at 6:17 PM on August 29, 2017: contributor

    Terminate string *pszExePath after readlink and before passing to operator <<.

    • ssize_t readlink(const char *pathname, char *buf, size_t bufsiz) does not append a null byte to buf.
    • Operator << expects a null-terminated string.
  2. practicalswift renamed this:
    Terminate string *pszExePath after readlink and before passing to operator <<
    [Qt] Terminate string *pszExePath after readlink and before passing to operator <<
    on Aug 29, 2017
  3. jonasschnelli commented at 9:11 PM on August 29, 2017: contributor

    Doesn't the memset to all zeros before the readlink ensures that it will be null byte terminated?

  4. jonasschnelli added the label GUI on Aug 29, 2017
  5. practicalswift commented at 7:54 AM on August 30, 2017: contributor

    @jonasschnelli Yes, you're correct but the current memset method seems a bit overkill for the task at hand. Instead of prematurely setting 1025 bytes to zero my suggestion is to set only one byte to zero when needed :-)

    In addition to being more efficient and less surprising, this has the added benefit of making some static analyzers happy - I've seen at least one static analyzer getting confused by the current "indirect" string termination logic via memset used here.

  6. laanwj commented at 7:20 PM on September 5, 2017: member

    IMO the PR title should be reworded - we already take care of NUL-terminating, just in a different way. This does not fix a potential bug or edge case as is implied.

    the current memset method seems a bit overkill for the task at hand.

    True in general, although this is not a performance sensitive place. Not sure this change is worth it.

  7. practicalswift renamed this:
    [Qt] Terminate string *pszExePath after readlink and before passing to operator <<
    [Qt] Terminate string *pszExePath after readlink and without using memset
    on Sep 6, 2017
  8. [Qt] Terminate string *pszExePath after readlink and without using memset 3a4401a6b8
  9. practicalswift force-pushed on Sep 6, 2017
  10. practicalswift commented at 7:03 PM on September 10, 2017: contributor

    PR title and commit message reworded :-)

  11. laanwj merged this on Oct 2, 2017
  12. laanwj closed this on Oct 2, 2017

  13. laanwj commented at 1:05 PM on October 2, 2017: member

    utACK 3a4401a This is obviously correct, but I suggest focusing on actual problems and issues in future PRs instead of "this looks better".

  14. laanwj referenced this in commit c5c77bdcc6 on Oct 2, 2017
  15. TheBlueMatt commented at 7:57 PM on October 3, 2017: member

    Postumous utACK, though feels like needless code churn, agree with @laanwj it just creates more review burden/time.

  16. Fabcien referenced this in commit cef845e734 on Aug 30, 2019
  17. jonspock referenced this in commit e4b20a2b2b on Dec 8, 2019
  18. jonspock referenced this in commit 53b091f15e on Dec 8, 2019
  19. jonspock referenced this in commit d0b08824f9 on Dec 8, 2019
  20. proteanx referenced this in commit 6e659c29b9 on Dec 12, 2019
  21. PastaPastaPasta referenced this in commit bb8a3e19c1 on Jan 17, 2020
  22. PastaPastaPasta referenced this in commit b26a3b80c3 on Jan 22, 2020
  23. PastaPastaPasta referenced this in commit df46947b8c on Jan 22, 2020
  24. PastaPastaPasta referenced this in commit 9340a0e45f on Jan 29, 2020
  25. PastaPastaPasta referenced this in commit 66d8b51f94 on Jan 29, 2020
  26. PastaPastaPasta referenced this in commit 21b7d3e81c on Jan 31, 2020
  27. Fuzzbawls referenced this in commit 71ed429370 on Feb 14, 2021
  28. ckti referenced this in commit 7ab6054da1 on Mar 28, 2021
  29. practicalswift deleted the branch on Apr 10, 2021
  30. gades referenced this in commit 9ac65a88d0 on Mar 10, 2022
  31. DrahtBot locked this on Aug 18, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me