Package: alpine Version: 2.24+dfsg1-1 When invoking file name tab completion in alpine (e.g. tabbing attachments) or alpine-pico (e.g. opening files), in case the last fully tpyed directory has a large st_size (larger than free system RAM), tabbing fails.
strace reveals (trying to attach in alpine):
-------------
stat("/home/<myuser>", {st_mode=S_IFDIR|0710, st_size=39307106551, ...}) = 0
mmap(NULL, 39307108352, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= -1 ENOMEM (Cannot allocate memory)
mmap(NULL, 39307108352, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= -1 ENOMEM (Cannot allocate memory)
brk(0x561a2882d000) = 0x5611019f7000
mmap(NULL, 39307243520, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= -1 ENOMEM (Cannot allocate memory)
write(1, "\7\33[33;1H "..., 144) = 144
write(1, "\33[33;1H\33[7mFile to attach: "..., 160) = 160
write(1, "\33[7mDow "..., 132) = 132
-------------
This can be traced to a malloc call in the getfnames() function in pico, used
in pico_fncomplete(),
which tries to allocate a buffer of size st_size of the directory, used as
best-guess size to hold the file names.
This breaks for file systems which report actual directory content size in
st_size (e.g. CephFS):
In that case, a malloc of macroscopic size (in this case >36 GB) is attempted upon each
press of "tab".
Upstream has already fixed the issue and it is part of the recent 2.25.1 tag:
https://repo.or.cz/alpine.git/blobdiff/9b7d799cadf5d17b408b52d948bfb05d96e01c12..bc15b12b7f13ec9c9cd855aae0e62be4d0ef9e31:/pico/osdep/filesys.c
(the buffer is re-alloced if too small anyways later in the code).
Cheers,
Oliver
smime.p7s
Description: S/MIME Cryptographic Signature

