Sfoglia il codice sorgente

Fix compile error with new fortification settings

Martijn Braam 6 mesi fa
parent
commit
86f824478a
2 ha cambiato i file con 6 aggiunte e 6 eliminazioni
  1. 5 5
      src/findconfig.c
  2. 1 1
      src/parse.c

+ 5 - 5
src/findconfig.c

@@ -11,10 +11,10 @@
 #endif
 
 static int
-find_device_by_model(char *conffile, char *model, int print)
+find_device_by_model(ssize_t maxlen, char *conffile, char *model, int print)
 {
 	// Check config/%model.conf in the current working directory
-	sprintf(conffile, "config/%s.conf", model);
+	snprintf(conffile, maxlen, "config/%s.conf", model);
 	if (print) {
 		printf("- %s\n", conffile);
 	}
@@ -23,7 +23,7 @@ find_device_by_model(char *conffile, char *model, int print)
 	}
 
 	// Check user overridden /etc/megapixels/config/%model.conf
-	sprintf(conffile, "%s/megapixels/config/%s.conf", SYSCONFDIR, model);
+	snprintf(conffile, maxlen, "%s/megapixels/config/%s.conf", SYSCONFDIR, model);
 	if (print) {
 		printf("- %s\n", conffile);
 	}
@@ -32,7 +32,7 @@ find_device_by_model(char *conffile, char *model, int print)
 	}
 
 	// Check packaged /usr/share/megapixels/config/%model.conf
-	sprintf(conffile, "%s/megapixels/config/%s.conf", DATADIR, model);
+	snprintf(conffile, maxlen, "%s/megapixels/config/%s.conf", DATADIR, model);
 	if (print) {
 		printf("- %s\n", conffile);
 	}
@@ -63,7 +63,7 @@ libmegapixels_find_config_verbose(char *configfile, int print)
 		}
 		*(modelptr++) = (char) c;
 		if (c == 0) {
-			if (find_device_by_model(configfile, model, print)) {
+			if (find_device_by_model(sizeof(model), configfile, model, print)) {
 				return 1;
 			}
 			modelptr = model;

+ 1 - 1
src/parse.c

@@ -19,7 +19,7 @@
 char *
 find_path_for_devnode(struct media_v2_intf_devnode devnode)
 {
-	char uevent_path[PATH_MAX];
+	char uevent_path[PATH_MAX] = "";
 	snprintf(uevent_path, PATH_MAX, "/sys/dev/char/%d:%d/uevent", devnode.major, devnode.minor);
 
 	FILE *fp = fopen(uevent_path, "r");