]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Coverity fixes
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 11 Dec 2022 20:34:44 +0000 (14:34 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 11 Dec 2022 20:34:44 +0000 (14:34 -0600)
scripts/build/log.c
scripts/jlibtool.c

index 5afafad3c5da3dc8769852d4f2eb2eae3758f18a..35a49ea8d7f0e9dfe9ef768ab3db9a7a3374d372 100644 (file)
@@ -38,8 +38,7 @@ void _make_vlog(char const *log_keyword, char const *file, int line, char const
        char    buffer[256];
        char    *p = buffer, *end = (p + (sizeof(buffer) - 1));
 
-       /* coverity[fixed_size_dest] */
-       strcpy(p, log_keyword);
+       strlcpy(p, log_keyword, (end - p) + 1);
        p += strlen(p);
        *p++ = ' ';
 
index 0808592c9d1588fb8eb01b8abbbe2bebbfbf5fe4..862c26598d41ed6071c370ef7266d330f583b6d8 100644 (file)
@@ -2709,7 +2709,8 @@ static int run_mode(command_t *cmd)
                break;
        case MODE_EXECUTE:
        {
-               char *l, libpath[PATH_MAX];
+               char libpath[PATH_MAX];
+               char *p = libpath, *end = p + (sizeof(libpath) - 1);
 
                if (!cmd->arglist->num) {
                        ERROR("No command to execute.\n");
@@ -2721,15 +2722,18 @@ static int run_mode(command_t *cmd)
                /*
                 *      jlibtool is in $(BUILD_DIR)/make/jlibtool
                 */
-               /* coverity[fixed_size_dest] */
-               strcpy(libpath, program);
+               strncpy(p, program, end - p);
+               *end = '\0';
 
                /*
                 *      Libraries are relative to jlibtool, in
                 *      $(BUILD_DIR)/lib/local/.libs/
                 */
-               l = strstr(libpath, "/make");
-               if (l) strcpy(l, "/lib/local/.libs");
+               p = strstr(libpath, "/make");
+               if (p) {
+                       strncpy(p, "/lib/local/.libs", end - p);
+                       *end = '\0';
+               }
 
                setenv(target->ld_library_path, libpath, 1);
                setenv(target->ld_library_path_local, libpath, 1);