Commit c219bd79 authored by Leah Neukirchen's avatar Leah Neukirchen

readlin: check if buffer is too small

parent 5c972c5e
......@@ -897,8 +897,8 @@ static const char *
readlin(const char *p, const char *alt)
{
static char b[PATH_MAX];
int r = readlink(p, b, sizeof b - 1);
if (r < 0)
ssize_t r = readlink(p, b, sizeof b - 1);
if (r < 0 || (size_t)r >= sizeof b - 1)
return alt;
b[r] = 0;
return b;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment