From 912aa3774e2889070b28ecd94df11ac228666457 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 29 Aug 2018 10:24:23 +0100 Subject: remove use of strcpy --- utils/filepath.c | 2 +- utils/filepath.h | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'utils') diff --git a/utils/filepath.c b/utils/filepath.c index ee5f107c9..9c1e7667b 100644 --- a/utils/filepath.c +++ b/utils/filepath.c @@ -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); } } diff --git a/utils/filepath.h b/utils/filepath.h index ad077e2ce..784264b33 100644 --- a/utils/filepath.h +++ b/utils/filepath.h @@ -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); -- cgit v1.2.3