mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-04-24 02:21:04 -07:00
unixfsys.d: fix symlink buffer grow
We were verifying `written == size' to check if there is something more to be read, but previously we did `size+=256', so this test was always a failure. Additionally we fix a bug (not reported anywhere) for symlinks which have 128+256n characters – '/' for directories and '\0' in the end wouldn't fit in this corner cases. Related to #295.
This commit is contained in:
parent
1cfb5016d8
commit
44178bd06c
1 changed files with 9 additions and 3 deletions
|
|
@ -161,8 +161,8 @@ current_dir(void) {
|
|||
size += 256;
|
||||
} while (ok == NULL);
|
||||
size = strlen((char*)output->base_string.self);
|
||||
if ((size + 1 /* / */ + 1 /* 0 */) >= output->base_string.dim) {
|
||||
/* Too large to host the trailing '/' */
|
||||
if ((size + 2) >= output->base_string.dim) {
|
||||
/* Too small to host the trailing '/' and '\0' */
|
||||
cl_object other = ecl_alloc_adjustable_base_string(size+2);
|
||||
strcpy((char*)other->base_string.self, (char*)output->base_string.self);
|
||||
output = other;
|
||||
|
|
@ -240,7 +240,13 @@ si_readlink(cl_object filename) {
|
|||
(char*)output->base_string.self, size);
|
||||
ecl_enable_interrupts();
|
||||
size += 256;
|
||||
} while (written == size);
|
||||
} while (written == size-256);
|
||||
if ((written + 2) > output->base_string.self) {
|
||||
/* Too small to host the trailing '/' and '\0' */
|
||||
cl_object other = ecl_alloc_adjustable_base_string(written+2);
|
||||
strcpy((char*)other->base_string.self, (char*)output->base_string.self);
|
||||
output = other;
|
||||
}
|
||||
output->base_string.self[written] = '\0';
|
||||
kind = file_kind((char*)output->base_string.self, FALSE);
|
||||
if (kind == @':directory') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue