gcc warns that:
warning: 'char* strncpy(char*, const char*, size_t)' specified bound 4096 equals destination size [-Wstringop-truncation]
Error-out when snprintf indicates that a truncation occurred.
Change-Id: I8c514da6b0ccb1a59d1555b02bfea2dd3c57febb
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
}
/* Concatenate the strings */
- snprintf(resolved_path, LTTNG_PATH_MAX, "%s%s", try_path_prev, cut_path);
+ const auto snprintf_ret =
+ snprintf(resolved_path, LTTNG_PATH_MAX, "%s%s", try_path_prev, cut_path);
+ if (snprintf_ret >= LTTNG_PATH_MAX) {
+ ERR("Path exceeded maximal allowed length while determining canonicalized absolute pathname");
+ goto error;
+ }
/* Free the allocated memory */
free(cut_path);