]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
shut up compiler warning
authorMatthew Newton <matthew-git@newtoncomputing.co.uk>
Thu, 7 Oct 2021 16:51:58 +0000 (17:51 +0100)
committerMatthew Newton <matthew-git@newtoncomputing.co.uk>
Thu, 7 Oct 2021 17:43:13 +0000 (18:43 +0100)
src/main/conffile.c

index 4a793cf27ed7d3d3b728ad76fe4fb1302dc8c846..bddb923af54ade4b4bf18b8e8f6f64af6382391c 100644 (file)
@@ -2516,6 +2516,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp,
                                 */
                                while ((dp = readdir(dir)) != NULL) {
                                        char const *p;
+                                       int slen;
 
                                        if (dp->d_name[0] == '.') continue;
 
@@ -2532,8 +2533,12 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp,
                                        }
                                        if (*p != '\0') continue;
 
-                                       snprintf(buf2, sizeof(buf2), "%s%s",
-                                                value, dp->d_name);
+                                       slen = snprintf(buf2, sizeof(buf2), "%s%s",
+                                                       value, dp->d_name);
+                                       if (slen >= (int) sizeof(buf2) || slen < 0) {
+                                               ERROR("%s: Full file path is too long.", dp->d_name);
+                                               return -1;
+                                       }
                                        if ((stat(buf2, &stat_buf) != 0) ||
                                            S_ISDIR(stat_buf.st_mode)) continue;