https://gitlab.synchro.net/main/sbbs/-/commit/1767046fd69fbcda29d09372
Modified Files:
src/sbbs3/js_filebase.cpp
Log Message:
js_filebase: initialize SMB_FILE_DIRECTORY for fresh ad-hoc (is_path) bases
For an is_path FileBase, js_open() called smb_open() directly instead
of smb_open_dir(). smb_open_dir() initializes a fresh file base by
setting status.attr = SMB_FILE_DIRECTORY (and any dir-specific limits)
then calling smb_create() to write the SMB header to disk. Plain
smb_open() does neither Ä it just opens the .shd file (creating an
empty one if absent) and reads existing status only if the file is
already big enough.
Without SMB_FILE_DIRECTORY in status.attr, smb_idxreclen() (smblib.c)
returns sizeof(idxrec_t) (smaller, msg-style) instead of
sizeof(fileidxrec_t). That meant smb_addfile() wrote a corrupted
.sid index Ä small msg records where the rest of FileBase expects
file records Ä and loadfilenames(), iterating the index using sizeof(fileidxrec_t), saw garbage / zero records. Net effect: add()
returned true, but get(), get_list(), and get_names() never found the
added file.
Reproducer:
var fb = new FileBase(system.temp_dir + "x", true);
fb.open();
fb.add({name: "f.dat", desc: "d", from: "u"});
fb.get("f.dat"); // -> null
fb.get_list().length; // -> 0
Fix: when js_open()'s !dirnum_is_valid (is_path) branch is taken and
smb_open() succeeds against an empty .shd, set status.attr =
SMB_FILE_DIRECTORY and call smb_create() Ä mirroring smb_open_dir()'s first-time-init for ad-hoc bases. Like the savemsg/votemsg fix in
e5ddda76d, this is a latent bug exposed when 93b4d946c added the
is_path constructor option.
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net