Skip to content

Handle path doesn't exist in fileutl_absolute_path #643

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

Merged
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
6 changes: 6 additions & 0 deletions src/util/file_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Date: January 2012
#include <cassert>

#include <fstream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <sstream>
Expand Down Expand Up @@ -255,6 +256,11 @@ std::string fileutl_absolute_path(std::string const &path)
return std::string(&(buffer[0]));
#else
char *absolute = realpath(path.c_str(), nullptr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpplint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cpplint script only finds problems in lines that have been changed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to fix also the issue in existing code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you underestimate how long it would take to lint all the existing code created for the security project. I suggest speaking to Reuben about clang.

if(absolute==NULL)
{
std::string error=std::strerror(errno);
throw std::ios::failure("Could not resolve absolute path ("+error+")");
}
std::string ret(absolute);
free(absolute);
return ret;
Expand Down