diff options
author | Andrew Bartlett <abartlet@samba.org> | 2019-11-11 13:53:33 +1300 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2019-11-15 18:48:27 +0000 |
commit | f1fa0d3b9dfef17a5129b53695fa454f1a8b8b68 (patch) | |
tree | 0bf7028be3f53c6f4fecbe5b987790cc3e2a40f1 /librpc/rpc | |
parent | 5e63e54f589b25af550f0d4e28e3c28e0a337c0d (diff) | |
download | samba-f1fa0d3b9dfef17a5129b53695fa454f1a8b8b68.tar.gz |
librpc: Use the fact that file_save() now uses O_EXCL in dcerpc_log_packet()
This avoids a race with file_exist() and demostrates a better
way to use this function.
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Nov 15 18:48:27 UTC 2019 on sn-devel-184
Diffstat (limited to 'librpc/rpc')
-rw-r--r-- | librpc/rpc/dcerpc_util.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/librpc/rpc/dcerpc_util.c b/librpc/rpc/dcerpc_util.c index 01dc2e7061d..1fb3fa72075 100644 --- a/librpc/rpc/dcerpc_util.c +++ b/librpc/rpc/dcerpc_util.c @@ -1425,19 +1425,19 @@ void dcerpc_log_packet(const char *lockdir, for (i=0;i<num_examples;i++) { char *name=NULL; int ret; + bool saved; ret = asprintf(&name, "%s/rpclog/%s-%u.%d.%s", lockdir, ndr->name, opnum, i, (flags&NDR_IN)?"in":"out"); if (ret == -1) { return; } - if (!file_exist(name)) { - if (file_save(name, pkt->data, pkt->length)) { - DEBUG(10,("Logged rpc packet to %s\n", name)); - } - free(name); + + saved = file_save(name, pkt->data, pkt->length); + free(name); + if (saved) { + DBG_DEBUG("Logged rpc packet to %s\n", name); break; } - free(name); } } |