#include <sys/uio.h>
#include <sys/wait.h>
#include <unistd.h>
+#include <assert.h>
#include <elfutils/version.h>
#include <elfutils/libdwfl.h>
memcpy(t_node->fpath, STR_ANONY, STR_ANONY_LEN);
}
t_node->next = NULL;
- if (head == NULL) {
+ if (head == NULL || tail == NULL) {
+ assert(head == NULL);
+ assert(tail == NULL);
head = t_node;
tail = t_node;
} else {
fprintf(errfile, "Failed to fseek\n");
return;
}
- while ((cnt = fread(buf, sizeof(char), sizeof(buf), bufferfile)) != 0) {
+ while ((cnt = fread(buf, sizeof(char), sizeof(buf), bufferfile)) != 0 && !(feof(bufferfile) || ferror(bufferfile))) {
if (cnt != fwrite(buf, sizeof(char), cnt, outputfile))
break;
}
tid = pid;
}
+ mode_t oldmode = umask(0077);
if (mkstemp(bufferfile_path) < 0) {
fprintf(errfile, "Failed to create buffer file.\n");
return errno;
}
+ umask(oldmode);
+
if ((bufferfile = fopen(bufferfile_path, "w+")) == NULL) {
fprintf(errfile, "Failed to open buffer file.\n");
return errno;