[futils] Change signature of getEnv to take an int
While taking an EnVar as the parameter is more clear it has the disadvantage, that passing anything outside of the range of the enumeration is undefined behavior. The compiler could then optimize the range check in getEnv away (perfectly legal due to UB), leading to buffer overreads.
This commit is contained in:
@@ -59,11 +59,11 @@ namespace Exiv2
|
||||
// free functions
|
||||
/*!
|
||||
@brief Return the value of environmental variable.
|
||||
@param var The name of environmental variable.
|
||||
@param[in] var The name of environmental variable. Must be a member of the enumeration @ref EnVar.
|
||||
@return the value of environmental variable. If it's empty, the default value is returned.
|
||||
@throws std::out_of_range when an unexpected EnVar is given as input.
|
||||
*/
|
||||
EXIV2API std::string getEnv(EnVar var);
|
||||
EXIV2API std::string getEnv(int env_var);
|
||||
|
||||
/*!
|
||||
@brief Encode the input url.
|
||||
@@ -204,4 +204,4 @@ namespace Exiv2
|
||||
|
||||
} // namespace Exiv2
|
||||
|
||||
#endif // #ifndef FUTILS_HPP_
|
||||
#endif // #ifndef FUTILS_HPP_
|
||||
|
||||
Reference in New Issue
Block a user