/* 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);
* 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);
/* 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);
/* 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);
ret = fprintf(fp, "%d\n", pid);
if (ret < 0) {
PERROR("fprintf pid file");
+ goto error;
}
- fclose(fp);
+ if (fclose(fp)) {
+ PERROR("fclose");
+ }
DBG("Pid %d written in file %s", pid, filepath);
+ ret = 0;
error:
return ret;
}
*/
ret = flock(fd, LOCK_EX | LOCK_NB);
if (ret) {
- WARN("Could not get lock file %s, another instance is running.",
+ ERR("Could not get lock file %s, another instance is running.",
filepath);
- close(fd);
+ if (close(fd)) {
+ PERROR("close lock file");
+ }
fd = ret;
goto error;
}