libcli/auth: let msrpc_parse() return talloc'ed empty strings
[samba.git] / libcli / auth / msrpc_parse.c
index d499d9eb7a1f8bc60fe9568d685f60e1f720d8ca..74a7bcc27a8e8110367fbe6df68b02062bb00f60 100644 (file)
@@ -262,7 +262,11 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx,
 
                        ps = va_arg(ap, char **);
                        if (len1 == 0 && len2 == 0) {
-                               *ps = (char *)discard_const("");
+                               *ps = talloc_strdup(mem_ctx, "");
+                               if (*ps == NULL) {
+                                       ret = false;
+                                       goto cleanup;
+                               }
                        } else {
                                /* make sure its in the right format - be strict */
                                if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) {
@@ -289,7 +293,11 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx,
                                                goto cleanup;
                                        }
                                } else {
-                                       (*ps) = (char *)discard_const("");
+                                       *ps = talloc_strdup(mem_ctx, "");
+                                       if (*ps == NULL) {
+                                               ret = false;
+                                               goto cleanup;
+                                       }
                                }
                        }
                        break;
@@ -302,7 +310,11 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx,
                        ps = (char **)va_arg(ap, char **);
                        /* make sure its in the right format - be strict */
                        if (len1 == 0 && len2 == 0) {
-                               *ps = (char *)discard_const("");
+                               *ps = talloc_strdup(mem_ctx, "");
+                               if (*ps == NULL) {
+                                       ret = false;
+                                       goto cleanup;
+                               }
                        } else {
                                if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) {
                                        ret = false;
@@ -325,7 +337,11 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx,
                                                goto cleanup;
                                        }
                                } else {
-                                       (*ps) = (char *)discard_const("");
+                                       *ps = talloc_strdup(mem_ctx, "");
+                                       if (*ps == NULL) {
+                                               ret = false;
+                                               goto cleanup;
+                                       }
                                }
                        }
                        break;