In the function "resourced_proc_dump" from src/process/proc-main.c, it
concatenates directory and filename and writes it into a buffer using
snprintf.
In this situation, the gcc-13 compiler complains about: the length of
directory + filename can be greater than the size of the buffer, so
it should be handled.
It is already handled by checking the lengths of the directory &
filename but the compiler don't know about it.
To fix this situation, codes for checking the return value of snprintf
have been added.
Change-Id: I2776c5164c57323212e09377ca0eff1f55279ec6
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
char buf[MAX_PATH_LENGTH];
char filename[MAX_NAME_LENGTH];
int name_len;
+ int path_len;
_cleanup_fclose_ FILE *f = NULL;
if (dirpath) {
return;
}
- snprintf(buf, MAX_PATH_LENGTH, "%s%s", dirpath, filename);
+ path_len = snprintf(buf, MAX_PATH_LENGTH, "%s%s", dirpath, filename);
+
+ if (path_len < 0) {
+ _E("[PROCESS] Failed to write dump path");
+ return;
+ }
+
+ if (MAX_PATH_LENGTH <= path_len) {
+ _E("[PROCESS] Dump path is too long");
+ return;
+ }
+
f = fopen(buf, "w+");
}
proc_dump_process_list(f);