mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-02 12:06:44 +00:00
libc: 'readlink' returns non-zero terminated buffer
Make so to handle zero termination correctly for 'stat' calls and for debugging output. Issue #1048
This commit is contained in:
parent
b7575319bf
commit
1b1693e6ff
@ -205,10 +205,13 @@ static void resolve_symlinks(char const *path, Absolute_path &resolved_path)
|
|||||||
PDBGV("found symlink: %s", next_iteration_working_path.base());
|
PDBGV("found symlink: %s", next_iteration_working_path.base());
|
||||||
FNAME_FUNC_WRAPPER_GENERIC(res = , readlink,
|
FNAME_FUNC_WRAPPER_GENERIC(res = , readlink,
|
||||||
next_iteration_working_path.base(),
|
next_iteration_working_path.base(),
|
||||||
symlink_target, sizeof(symlink_target));
|
symlink_target, sizeof(symlink_target) - 1);
|
||||||
if (res < 1)
|
if (res < 1)
|
||||||
throw Symlink_resolve_error();
|
throw Symlink_resolve_error();
|
||||||
|
|
||||||
|
/* zero terminate target */
|
||||||
|
symlink_target[res] = 0;
|
||||||
|
|
||||||
if (symlink_target[0] == '/')
|
if (symlink_target[0] == '/')
|
||||||
/* absolute target */
|
/* absolute target */
|
||||||
next_iteration_working_path.import(symlink_target, cwd().base());
|
next_iteration_working_path.import(symlink_target, cwd().base());
|
||||||
|
@ -659,7 +659,8 @@ class Plugin : public Libc::Plugin
|
|||||||
|
|
||||||
ssize_t result = read(fd, buf, bufsiz);
|
ssize_t result = read(fd, buf, bufsiz);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
PDBG("result = %zd, buf = %s", result, buf);
|
PDBG("result = %zd, buf = %s", result, buf[result] ?
|
||||||
|
"<not zero terminated>" : buf);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user