remove use of strcpy

This commit is contained in:
Vincent Sanders 2018-08-29 10:24:23 +01:00
parent 9142bab736
commit 912aa3774e
2 changed files with 11 additions and 5 deletions

View File

@ -165,7 +165,7 @@ filepath_sfinddef(char **respathv,
snprintf(t, PATH_MAX, "%s/%s", def, filename);
}
if (realpath(t, ret) == NULL) {
strcpy(ret, t);
strncpy(ret, t, PATH_MAX);
}
}

View File

@ -69,10 +69,10 @@ char *filepath_findfile(const char *format, ...);
* normalised file name of the first acessible file or NULL if no file
* can be found in any of the resource paths.
*
* @param respathv The resource path vector to iterate.
* @param filepath The buffer to place the result in.
* @param filename The filename of the resource to search for.
* @return A pointer to filepath if a target is found or NULL if not.
* \param respathv The resource path vector to iterate.
* \param filepath The buffer to place the result in.
* \param filename The filename of the resource to search for.
* \return A pointer to filepath if a target is found or NULL if not.
*/
char *filepath_sfind(char **respathv, char *filepath, const char *filename);
@ -93,6 +93,12 @@ char *filepath_find(char **respathv, const char *filename);
* is used as an additional path element to search, if that still
* fails the returned path is set to the concatination of the default
* path and the filename.
*
* \param respathv The resource path vector to iterate.
* \param filepath The buffer to place the result in. Must have space for PATH_MAX bytes.
* \param filename The filename of the resource to search for.
* \param def The default path to use
* \return A pointer to filepath if a target is found or the default if not
*/
char *filepath_sfinddef(char **respathv, char *filepath, const char *filename,
const char *def);