Bug 3002

Summary: Incorrect left alignment in progressmeter.c
Product: Portable OpenSSH Reporter: Artiom Vaskov <velemas>
Component: scpAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED FIXED    
Severity: major CC: dtucker
Priority: P5    
Version: 8.0p1   
Hardware: Other   
OS: Other   
Bug Depends on:    
Bug Blocks: 2988    

Description Artiom Vaskov 2019-05-03 00:46:32 AEST
On my system (BS2000/390) new progress meter works incorrectly. It outputs grabage beyond buffer boundaries:

...
scp  50% 7808KB 913.9KB/s   00:08 ETA▒▒0▒▒
scp  55% 8631KB 906.3KB/s   00:07 ETA▒▒0▒▒
scp  56% 8731KB 825.7KB/s   00:08 ETA▒▒0▒▒
scp  58% 9131KB 783.4KB/s   00:08 ETA▒▒0▒▒
scp  71%   11MB 908.0KB/s   00:04 ETA▒▒0▒▒
scp  74%   11MB 860.9KB/s   00:04 ETA▒▒0▒▒
scp  75%   11MB 785.0KB/s   00:04 ETA▒▒0▒▒
scp  84%   13MB 858.7KB/s   00:02 ETA▒▒0▒▒
scp  87%   13MB 822.6KB/s   00:02 ETA▒▒0▒▒
scp  88%   13MB 751.8KB/s   00:02 ETA▒▒0▒▒
scp  89%   14MB 687.8KB/s   00:02 ETA▒▒0▒▒
scp  95%   14MB 708.2KB/s   00:01 ETA▒▒0▒▒
...

Quick investigation showed that culprit is <file_len * -1> in progressmeter.c:

snmprintf(buf+1, sizeof(buf)-1 , &file_len, "%*s",
                   file_len * -1, file);

If I change it to:
snmprintf(buf+1, sizeof(buf)-1 , &file_len, "%-*s",
                   file_len, file);

it fixes the issue.

"%-*s" is a correct left alignment in printf-like functions.
Comment 1 Darren Tucker 2019-05-03 16:07:13 AEST
thanks for the analysis and report.  this has been fixed and will be in 8.1.
Comment 2 Damien Miller 2021-04-23 15:09:19 AEST
closing resolved bugs as of 8.6p1 release