2
0
mirror of https://github.com/rehlds/metamod-r.git synced 2025-01-14 23:57:57 +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 // Much like realpath, buffer pointed to by fullpath is assumed to be
// able to store a string of PATH_MAX length. // 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]; char buf[PATH_MAX];
@ -184,8 +184,7 @@ char* full_gamedir_path(const char* path, char* fullpath)
// Remove relative path components, if possible. // Remove relative path components, if possible.
if (!realpath(buf, fullpath)) { if (!realpath(buf, fullpath)) {
META_DEBUG(4, "Unable to get realpath for '%s': %s", buf, strerror(errno)); META_DEBUG(4, "Unable to get realpath for '%s': %s", buf, strerror(errno));
Q_strncpy(fullpath, path, sizeof fullpath - 1); Q_strlcpy(fullpath, path);
fullpath[sizeof fullpath - 1] = '\0';
} }
// Replace backslashes, etc. // 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_valid_path(const char *path);
bool is_platform_postfix(const char *pf); bool is_platform_postfix(const char *pf);
bool is_file_exists_in_gamedir(const char *path); 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); bool mem_compare(const char* addr, const char* pattern, size_t len);
void NORETURN Sys_Error(const char *error, ...); void NORETURN Sys_Error(const char *error, ...);