1 |
From 7c26fab82d668199756ebf24a96c46c102250c6a Mon Sep 17 00:00:00 2001 |
2 |
From: Stefan Metzmacher <metze@samba.org> |
3 |
Date: Mon, 9 May 2016 16:14:31 +0200 |
4 |
Subject: [PATCH] libcli/auth: let msrpc_parse() return talloc'ed empty strings |
5 |
|
6 |
This make it more predictable for the callers. |
7 |
|
8 |
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11912 |
9 |
BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1334356 |
10 |
BUG: https://launchpad.net/bugs/1578576 |
11 |
|
12 |
Signed-off-by: Stefan Metzmacher <metze@samba.org> |
13 |
|
14 |
Autobuild-User(master): Stefan Metzmacher <metze@samba.org> |
15 |
Autobuild-Date(master): Mon May 9 22:27:21 CEST 2016 on sn-devel-144 |
16 |
|
17 |
(cherry picked from commit 58a83236294117d32d9883ac3024f81fa1730a87) |
18 |
--- |
19 |
libcli/auth/msrpc_parse.c | 24 ++++++++++++++++++++---- |
20 |
1 file changed, 20 insertions(+), 4 deletions(-) |
21 |
|
22 |
diff --git a/libcli/auth/msrpc_parse.c b/libcli/auth/msrpc_parse.c |
23 |
index d499d9e..74a7bcc 100644 |
24 |
--- a/libcli/auth/msrpc_parse.c |
25 |
+++ b/libcli/auth/msrpc_parse.c |
26 |
@@ -262,7 +262,11 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, |
27 |
|
28 |
ps = va_arg(ap, char **); |
29 |
if (len1 == 0 && len2 == 0) { |
30 |
- *ps = (char *)discard_const(""); |
31 |
+ *ps = talloc_strdup(mem_ctx, ""); |
32 |
+ if (*ps == NULL) { |
33 |
+ ret = false; |
34 |
+ goto cleanup; |
35 |
+ } |
36 |
} else { |
37 |
/* make sure its in the right format - be strict */ |
38 |
if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) { |
39 |
@@ -289,7 +293,11 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, |
40 |
goto cleanup; |
41 |
} |
42 |
} else { |
43 |
- (*ps) = (char *)discard_const(""); |
44 |
+ *ps = talloc_strdup(mem_ctx, ""); |
45 |
+ if (*ps == NULL) { |
46 |
+ ret = false; |
47 |
+ goto cleanup; |
48 |
+ } |
49 |
} |
50 |
} |
51 |
break; |
52 |
@@ -302,7 +310,11 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, |
53 |
ps = (char **)va_arg(ap, char **); |
54 |
/* make sure its in the right format - be strict */ |
55 |
if (len1 == 0 && len2 == 0) { |
56 |
- *ps = (char *)discard_const(""); |
57 |
+ *ps = talloc_strdup(mem_ctx, ""); |
58 |
+ if (*ps == NULL) { |
59 |
+ ret = false; |
60 |
+ goto cleanup; |
61 |
+ } |
62 |
} else { |
63 |
if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) { |
64 |
ret = false; |
65 |
@@ -325,7 +337,11 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, |
66 |
goto cleanup; |
67 |
} |
68 |
} else { |
69 |
- (*ps) = (char *)discard_const(""); |
70 |
+ *ps = talloc_strdup(mem_ctx, ""); |
71 |
+ if (*ps == NULL) { |
72 |
+ ret = false; |
73 |
+ goto cleanup; |
74 |
+ } |
75 |
} |
76 |
} |
77 |
break; |
78 |
-- |
79 |
1.9.1 |
80 |
|