len = smb_len_tcp(data)+4;
for (i=1;i<100;i++) {
- if (asprintf(&fname, "/tmp/%s.%d.%s", name, i,
- type ? "req" : "resp") == -1) {
+ fname = talloc_asprintf(talloc_tos(),
+ "/tmp/%s.%d.%s",
+ name,
+ i,
+ type ? "req" : "resp");
+ if (fname == NULL) {
return;
}
fd = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0644);
if (fd != -1 || errno != EEXIST) break;
+ TALLOC_FREE(fname);
}
if (fd != -1) {
ssize_t ret = write(fd, data, len);
close(fd);
DEBUG(0,("created %s len %lu\n", fname, (unsigned long)len));
}
- SAFE_FREE(fname);
+ TALLOC_FREE(fname);
}
/****************************************************************************