- /*
- * have to construct the string bit by bit. sprintf can't do it in one.
- * first field is null, so string is \0<user>\0<password>
- */
- *a = 0;
- a++;
-
- g_snprintf (a, b64len - 1, "%s", session->user);
-
- b64cnt = strlen(session->user)+1;
- a += b64cnt;
-
- g_snprintf (a, b64len - b64cnt - 1, "%s", session->pass);
- b64cnt += strlen(session->pass) + 1;
-
- /*
- * reuse the char *ptr to offset into the textbuf to meld
- * the plaintext ESMTP message and the base64 string value
- */
- strcpy(buf, "AUTH PLAIN ");
- a = buf + strlen(buf);
- base64_encode(a, b64buf, b64cnt);
+ /* "\0user\0password" */
+ len = sprintf(buf, "%c%s%c%s", '\0', session->user, '\0', session->pass);
+ b64buf = g_base64_encode(buf, len);
+ out = g_strconcat("AUTH PLAIN ", b64buf, NULL);
+ g_free(b64buf);