s3:winbindd: make use of talloc_string_sub2() in generate_krb5_ccache()
authorStefan Metzmacher <metze@samba.org>
Wed, 26 Feb 2014 19:16:26 +0000 (20:16 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 25 Nov 2014 06:25:45 +0000 (07:25 +0100)
This way we don't pass a given format string to talloc_asprintf().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/winbindd/winbindd_pam.c

index 53519375c7fa4a3d5069003bce9202d3599fe98d..d56d2fa23eabf30c15450d03e79ba3e4fe16cfac 100644 (file)
@@ -512,7 +512,20 @@ static const char *generate_krb5_ccache(TALLOC_CTX *mem_ctx,
                                p++;
 
                                if (p != NULL && *p == 'u' && strchr(p, '%') == NULL) {
-                                       gen_cc = talloc_asprintf(mem_ctx, type, uid);
+                                       char uid_str[sizeof("18446744073709551615")];
+
+                                       snprintf(uid_str, sizeof(uid_str), "%u", uid);
+
+                                       gen_cc = talloc_string_sub2(mem_ctx,
+                                                       type,
+                                                       "%u",
+                                                       uid_str,
+                                                       /* remove_unsafe_characters */
+                                                       false,
+                                                       /* replace_once */
+                                                       true,
+                                                       /* allow_trailing_dollar */
+                                                       false);
                                }
                        }
                }