simon-git: putty (master): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Tue Jan 21 20:39:26 GMT 2020


TL;DR:
  88d5948e Fix undefined behaviour in safegrowarray.
  5891142a New functions to shrink a strbuf.
  cd6bc14f Use strbuf to store results in prompts_t.

Repository:     https://git.tartarus.org/simon/putty.git
On the web:     https://git.tartarus.org/?p=simon/putty.git
Branch updated: master
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2020-01-21 20:39:26

commit 88d5948ead1226a0e364980d93d19fb9f5124f33
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=88d5948ead1226a0e364980d93d19fb9f5124f33;hp=02d0990bd576a7cb5a816684cea5387f4fc46c01
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Jan 21 20:04:15 2020 +0000

    Fix undefined behaviour in safegrowarray.
    
    UBsan points out that if the input pointer is NULL, we'll pass it to
    memcpy, which is technically illegal by the C standard _even_ if the
    length you pass with it is zero.

 memory.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

commit 5891142aee5cab4aedd4a6be32e80fba806f3326
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=5891142aee5cab4aedd4a6be32e80fba806f3326;hp=88d5948ead1226a0e364980d93d19fb9f5124f33
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Jan 21 20:16:28 2020 +0000

    New functions to shrink a strbuf.
    
    These are better than my previous approach of just assigning to
    sb->len, because firstly they check by assertion that the new length
    is within range, and secondly they preserve the invariant that the
    byte stored in the buffer just after the length runs out is \0.
    
    Switched to using the new functions everywhere a grep could turn up
    opportunities.

 misc.h             |  3 +++
 pscp.c             |  8 ++++----
 scpserver.c        |  6 +++---
 ssh1login-server.c |  2 +-
 ssh1login.c        |  2 +-
 ssh2kex-server.c   |  2 +-
 ssh2transport.c    |  6 +++---
 ssh2userauth.c     |  2 +-
 sshverstring.c     |  3 +--
 telnet.c           |  4 ++--
 terminal.c         | 10 +++++-----
 testcrypt.c        |  2 +-
 unix/gtkdlg.c      |  2 +-
 unix/uxnet.c       |  4 ++--
 unix/uxstore.c     |  2 +-
 utils.c            | 14 ++++++++++++++
 windows/winpgnt.c  |  2 +-
 17 files changed, 45 insertions(+), 29 deletions(-)

commit cd6bc14f04382127a6617e10a82beb0232675d70
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=cd6bc14f04382127a6617e10a82beb0232675d70;hp=5891142aee5cab4aedd4a6be32e80fba806f3326
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Jan 21 20:19:47 2020 +0000

    Use strbuf to store results in prompts_t.
    
    UBsan pointed out another memcpy from NULL (again with length 0) in
    the prompts_t system. When I looked at it, I realised that firstly
    prompt_ensure_result_size was an early not-so-good implementation of
    sgrowarray_nm that would benefit from being replaced with a call to
    the real one, and secondly, the whole system for storing prompt
    results should really have been replaced with strbufs with the no-move
    option, because that's doing all the same jobs better.
    
    So, now each prompt_t holds a strbuf in place of its previous manually
    managed string. prompt_ensure_result_size is gone (the console
    prompt-reading functions use strbuf_append, and everything else just
    adds to the strbuf in the usual marshal.c way). New functions exist to
    retrieve a prompt_t's result, either by reference or copied.

 cmdgen.c          | 11 ++++++-----
 misc.c            | 36 +++++++++++-------------------------
 putty.h           | 18 +++---------------
 rlogin.c          |  6 ++++--
 ssh1login.c       | 18 +++++++++++-------
 ssh2userauth.c    | 26 +++++++++++++-------------
 terminal.c        | 15 +++++----------
 unix/uxcons.c     | 23 +++++++++++------------
 unix/uxpgnt.c     |  2 +-
 windows/wincons.c | 30 ++++++++++++++----------------
 10 files changed, 79 insertions(+), 106 deletions(-)



More information about the tartarus-commits mailing list