summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-06-28 13:20:18 +0200
committerAndreas Schneider <asn@samba.org>2010-06-29 11:12:12 +0200
commit1db7356fa17cb3aeffcf4aff2149eaceaa5a62ea (patch)
tree12f5f0e1a59d6570dd0159ba814e6644d457d332 /source3
parente52f3d8637c7af2f0ea57954c7f13389f5a1e125 (diff)
downloadsamba-1db7356fa17cb3aeffcf4aff2149eaceaa5a62ea.tar.gz
samba-1db7356fa17cb3aeffcf4aff2149eaceaa5a62ea.tar.bz2
samba-1db7356fa17cb3aeffcf4aff2149eaceaa5a62ea.zip
s3-net: Use talloc_asprintf and return if file is in wrong format.
Found by clang-analyzer.
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/net_rpc_printer.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index b75b195f4e..c398253616 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -490,12 +490,11 @@ static NTSTATUS net_copy_driverfile(struct net_context *c,
struct cli_state *cli_share_dst,
const char *file, const char *short_archi) {
- NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
const char *p;
char *src_name;
char *dst_name;
- char *version;
- char *filename;
+ char *version = NULL;
+ char *filename = NULL;
char *tok;
if (!file) {
@@ -512,29 +511,27 @@ static NTSTATUS net_copy_driverfile(struct net_context *c,
}
}
+ if (version == NULL || filename == NULL) {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
/* build source file name */
- if (asprintf(&src_name, "\\%s\\%s\\%s", short_archi, version, filename) < 0 )
+ src_name = talloc_asprintf(mem_ctx, "\\%s\\%s\\%s",
+ short_archi, version, filename);
+ if (src_name == NULL) {
return NT_STATUS_NO_MEMORY;
-
+ }
/* create destination file name */
- if (asprintf(&dst_name, "\\%s\\%s", short_archi, filename) < 0 )
- return NT_STATUS_NO_MEMORY;
+ dst_name = talloc_asprintf(mem_ctx, "\\%s\\%s", short_archi, filename);
+ if (dst_name == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
/* finally copy the file */
- nt_status = net_copy_file(c, mem_ctx, cli_share_src, cli_share_dst,
- src_name, dst_name, false, false, false, true);
- if (!NT_STATUS_IS_OK(nt_status))
- goto out;
-
- nt_status = NT_STATUS_OK;
-
-out:
- SAFE_FREE(src_name);
- SAFE_FREE(dst_name);
-
- return nt_status;
+ return net_copy_file(c, mem_ctx, cli_share_src, cli_share_dst,
+ src_name, dst_name, false, false, false, true);
}
/**