/* pad with empty bytes */
pad_size = PAGE_ALIGN(valid_length)-valid_length;
if(pad_size) {
- tmp = malloc(pad_size);
- memset(tmp, 0, pad_size);
+ tmp = zmalloc(pad_size);
result = patient_write(buf_local->file_fd, tmp, pad_size);
if(result == -1) {
ERR("Error writing to buffer file");
int result;
int fd;
struct buffer_info_local *buf_local =
- malloc(sizeof(struct buffer_info_local));
+ zmalloc(sizeof(struct buffer_info_local));
if(!buf_local) {
ERR("could not allocate buffer_info_local struct");
trace_path = USTD_DEFAULT_TRACE_PATH;
}
- asprintf(&tmp, "%s/%u_%lld", trace_path, buf->pid, buf->pidunique);
+ if (asprintf(&tmp, "%s/%u_%lld", trace_path, buf->pid, buf->pidunique) < 0) {
+ ERR("on_open_buffer : asprintf failed (%s/%u_%lld)",
+ trace_path, buf->pid, buf->pidunique);
+ return 1;
+ }
result = create_dir_if_needed(tmp);
if(result == -1) {
ERR("could not create directory %s", tmp);
}
free(tmp);
- asprintf(&tmp, "%s/%u_%lld/%s", trace_path, buf->pid, buf->pidunique, buf->name);
+ if (asprintf(&tmp, "%s/%u_%lld/%s", trace_path, buf->pid, buf->pidunique, buf->name) < 0) {
+ ERR("on_open_buffer : asprintf failed (%s/%u_%lld/%s)",
+ trace_path, buf->pid, buf->pidunique, buf->name);
+ return 1;
+ }
result = fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 00600);
if(result == -1) {
PERROR("open");
struct libustd_callbacks *new_callbacks()
{
struct libustd_callbacks *callbacks =
- malloc(sizeof(struct libustd_callbacks));
+ zmalloc(sizeof(struct libustd_callbacks));
if(!callbacks)
return NULL;