X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fcommon%2Futils.c;h=203739c320707e55a3a3903cec27540c97339131;hb=135347bd92b3e432a973613e0e673db3b50e6044;hp=1d07cb31cc01511aedb781124de609277410075d;hpb=c9d424071aa532aa287fa86cfe02edbeded50e7b;p=lttng-tools.git diff --git a/src/common/utils.c b/src/common/utils.c index 1d07cb31c..203739c32 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -90,6 +90,10 @@ char *utils_partial_realpath(const char *path, char *resolved_path, size_t size) /* Cut the part we will be trying to resolve */ cut_path = strndup(path, next - path); + if (cut_path == NULL) { + PERROR("strndup"); + goto error; + } /* Try to resolve this part */ try_path = realpath((char *)cut_path, NULL); @@ -143,6 +147,10 @@ char *utils_partial_realpath(const char *path, char *resolved_path, size_t size) * path are pointers for the same memory space */ cut_path = strdup(prev); + if (cut_path == NULL) { + PERROR("strdup"); + goto error; + } /* Concatenate the strings */ snprintf(resolved_path, size, "%s%s", try_path_prev, cut_path); @@ -216,7 +224,10 @@ char *utils_expand_path(const char *path) /* We prepare the start_path not containing it */ start_path = strndup(absolute_path, next - absolute_path); - + if (!start_path) { + PERROR("strndup"); + goto error; + } /* And we concatenate it with the part after this string */ snprintf(absolute_path, PATH_MAX, "%s%s", start_path, next + 2); @@ -233,6 +244,10 @@ char *utils_expand_path(const char *path) /* Then we prepare the start_path not containing it */ start_path = strndup(absolute_path, previous - absolute_path); + if (!start_path) { + PERROR("strndup"); + goto error; + } /* And we concatenate it with the part after the '/../' */ snprintf(absolute_path, PATH_MAX, "%s%s", start_path, next + 4);