File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -219,13 +219,14 @@ Path readLink(const Path & path)
219219 struct stat st = lstat (path);
220220 if (!S_ISLNK (st.st_mode ))
221221 throw Error (format (" '%1%' is not a symlink" ) % path);
222- char buf[st.st_size ];
223- ssize_t rlsize = readlink (path.c_str (), buf, st.st_size );
222+ auto bufSize = std::max (st.st_size , (off_t ) PATH_MAX + 1 );
223+ char buf[bufSize];
224+ ssize_t rlsize = readlink (path.c_str (), buf, bufSize);
224225 if (rlsize == -1 )
225226 throw SysError (format (" reading symbolic link '%1%'" ) % path);
226- else if (rlsize > st. st_size )
227+ else if (rlsize > bufSize )
227228 throw Error (format (" symbolic link '%1%' size overflow %2% > %3%" )
228- % path % rlsize % st. st_size );
229+ % path % rlsize % bufSize );
229230 return string (buf, rlsize);
230231}
231232
You can’t perform that action at this time.
0 commit comments