diff options
Diffstat (limited to 'source3/rpc_parse/parse_prs.c')
-rw-r--r-- | source3/rpc_parse/parse_prs.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c index a30e96772a..4abf63e71d 100644 --- a/source3/rpc_parse/parse_prs.c +++ b/source3/rpc_parse/parse_prs.c @@ -28,7 +28,7 @@ /** * Dump a prs to a file: from the current location through to the end. **/ -void prs_dump(char *name, int v, prs_struct *ps) +void prs_dump(const char *name, int v, prs_struct *ps) { prs_dump_region(name, v, ps, ps->data_offset, ps->buffer_size); } @@ -36,7 +36,7 @@ void prs_dump(char *name, int v, prs_struct *ps) /** * Dump from the start of the prs to the current location. **/ -void prs_dump_before(char *name, int v, prs_struct *ps) +void prs_dump_before(const char *name, int v, prs_struct *ps) { prs_dump_region(name, v, ps, 0, ps->data_offset); } @@ -44,18 +44,22 @@ void prs_dump_before(char *name, int v, prs_struct *ps) /** * Dump everything from the start of the prs up to the current location. **/ -void prs_dump_region(char *name, int v, prs_struct *ps, +void prs_dump_region(const char *name, int v, prs_struct *ps, int from_off, int to_off) { int fd, i; - pstring fname; + char *fname = NULL; ssize_t sz; if (DEBUGLEVEL < 50) return; for (i=1;i<100;i++) { if (v != -1) { - slprintf(fname,sizeof(fname)-1, "/tmp/%s_%d.%d.prs", name, v, i); + if (asprintf(&fname,"/tmp/%s_%d.%d.prs", name, v, i) < 0) { + return; + } } else { - slprintf(fname,sizeof(fname)-1, "/tmp/%s.%d.prs", name, i); + if (asprintf(&fname,"/tmp/%s.%d.prs", name, i) < 0) { + return; + } } fd = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0644); if (fd != -1 || errno != EEXIST) break; @@ -69,6 +73,7 @@ void prs_dump_region(char *name, int v, prs_struct *ps, DEBUG(0,("created %s\n", fname)); } } + SAFE_FREE(fname); } /******************************************************************* |