diff --git a/libports/src/lib/libc/file_operations.cc b/libports/src/lib/libc/file_operations.cc index db12c28f43..e4383c5cb4 100644 --- a/libports/src/lib/libc/file_operations.cc +++ b/libports/src/lib/libc/file_operations.cc @@ -205,10 +205,13 @@ static void resolve_symlinks(char const *path, Absolute_path &resolved_path) PDBGV("found symlink: %s", next_iteration_working_path.base()); FNAME_FUNC_WRAPPER_GENERIC(res = , readlink, next_iteration_working_path.base(), - symlink_target, sizeof(symlink_target)); + symlink_target, sizeof(symlink_target) - 1); if (res < 1) throw Symlink_resolve_error(); + /* zero terminate target */ + symlink_target[res] = 0; + if (symlink_target[0] == '/') /* absolute target */ next_iteration_working_path.import(symlink_target, cwd().base()); diff --git a/libports/src/lib/libc_fs/plugin.cc b/libports/src/lib/libc_fs/plugin.cc index b69dcafa79..0efaf9f337 100644 --- a/libports/src/lib/libc_fs/plugin.cc +++ b/libports/src/lib/libc_fs/plugin.cc @@ -659,7 +659,8 @@ class Plugin : public Libc::Plugin ssize_t result = read(fd, buf, bufsiz); if (verbose) - PDBG("result = %zd, buf = %s", result, buf); + PDBG("result = %zd, buf = %s", result, buf[result] ? + "" : buf); close(fd); return result;