2
0
mirror of https://github.com/rehlds/metamod-r.git synced 2025-01-13 23:28:23 +03:00

Bugfix: use size of buffer instead pointer

This commit is contained in:
s1lent 2017-11-18 23:23:17 +07:00
parent 41be316e12
commit 2f1df890bd
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
2 changed files with 3 additions and 4 deletions

View File

@ -169,7 +169,7 @@ bool is_file_exists_in_gamedir(const char* path)
//
// Much like realpath, buffer pointed to by fullpath is assumed to be
// able to store a string of PATH_MAX length.
char* full_gamedir_path(const char* path, char* fullpath)
char* full_gamedir_path(const char* path, char (&fullpath)[PATH_MAX])
{
char buf[PATH_MAX];
@ -184,8 +184,7 @@ char* full_gamedir_path(const char* path, char* fullpath)
// Remove relative path components, if possible.
if (!realpath(buf, fullpath)) {
META_DEBUG(4, "Unable to get realpath for '%s': %s", buf, strerror(errno));
Q_strncpy(fullpath, path, sizeof fullpath - 1);
fullpath[sizeof fullpath - 1] = '\0';
Q_strlcpy(fullpath, path);
}
// Replace backslashes, etc.

View File

@ -32,7 +32,7 @@ bool is_abs_path(const char *path);
bool is_valid_path(const char *path);
bool is_platform_postfix(const char *pf);
bool is_file_exists_in_gamedir(const char *path);
char *full_gamedir_path(const char *path, char *fullpath);
char *full_gamedir_path(const char *path, char (&fullpath)[PATH_MAX]);
bool mem_compare(const char* addr, const char* pattern, size_t len);
void NORETURN Sys_Error(const char *error, ...);