Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readlinknul(): Minor tweaks #1107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/fs/readlink/readlinknul.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,22 @@ inline int readlinknul(const char *restrict link, char *restrict buf,
inline int
readlinknul(const char *restrict link, char *restrict buf, size_t size)
{
ssize_t len;
size_t len;
ssize_t r;

len = readlink(link, buf, size);
if (len == -1)
r = readlink(link, buf, size);
if (r == -1)
return -1;

len = r;
if (len == size) {
stpcpy(&buf[size-1], "");
errno = E2BIG;
return -1;
}

stpcpy(&buf[len], "");
return len;
return 0;
}


Expand Down
Loading