simon-git: putty (main): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Tue Jul 26 12:51:51 BST 2022


TL;DR:
  138df73e Windows printing: handle failure of EnumPrinters.

Repository:     https://git.tartarus.org/simon/putty.git
On the web:     https://git.tartarus.org/?p=simon/putty.git
Branch updated: main
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2022-07-26 12:51:51

commit 138df73e81ddc732d71d66d8a7af2db2f0d826c4
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=138df73e81ddc732d71d66d8a7af2db2f0d826c4;hp=a33cf2240ef44c68537b116440c3184460e62bff
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Jul 26 12:42:17 2022 +0100

    Windows printing: handle failure of EnumPrinters.
    
    A user reports that if the Print Spooler service is disabled via
    services.msc, then PuTTY can report 'Out of memory!' when you try to
    open the Terminal config pane, which is the one containing the combo
    box enumerating the available printers.
    
    Apparently this is because the call to EnumPrinters failed with the
    error code other than the expected ERROR_INSUFFICIENT_BUFFER, and in
    the process, left garbage in the pcbNeeded output parameter. That
    wouldn't be too surprising if it had simply _not written_ to that
    parameter and therefore it was never initialised at all in the calling
    function printer_add_enum. But in fact, printer_add_enum *does*
    precautionarily initialise needed=0 before the initial call to
    EnumPrinters. So EnumPrinters must have actively written one of its
    *own* uninitialised variables into it!
    
    Anyway, the obvious fix is to distinguish ERROR_INSUFFICIENT_BUFFER
    from any other kind of EnumPrinters failure (in fact turning off Print
    Spooler seems to lead to RPC_S_SERVER_UNAVAILABLE), and not attempt to
    proceed in the case of other failures.

 windows/printing.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)



More information about the tartarus-commits mailing list