[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS gsasl/lib/plain
From: |
gsasl-commit |
Subject: |
CVS gsasl/lib/plain |
Date: |
Tue, 30 Nov 2004 04:53:33 +0100 |
Update of /home/cvs/gsasl/lib/plain
In directory dopio:/tmp/cvs-serv3198
Modified Files:
client.c
Log Message:
Don't NFKC, align with draft-ietf-sasl-plain-05.
--- /home/cvs/gsasl/lib/plain/client.c 2004/11/29 17:53:28 1.10
+++ /home/cvs/gsasl/lib/plain/client.c 2004/11/30 03:53:33 1.11
@@ -39,77 +39,44 @@
const char *input, size_t input_len,
char **output, size_t * output_len)
{
- char *authzid = NULL, *authid = NULL, *password = NULL;
+ const char *authzid = gsasl_property_get (sctx, GSASL_AUTHZID);
+ const char *authid = gsasl_property_get (sctx, GSASL_AUTHID);
+ const char *password = gsasl_property_get (sctx, GSASL_PASSWORD);
size_t authzidlen = 0, authidlen = 0, passwordlen = 0;
- const char *p;
- int res;
+ char *out;
- p = gsasl_property_get (sctx, GSASL_AUTHZID);
- if (p)
- {
- authzid = gsasl_stringprep_nfkc (p, -1);
- if (authzid == NULL)
- {
- res = GSASL_UNICODE_NORMALIZATION_ERROR;
- goto end;
- }
- authzidlen = strlen (authzid);
- }
+ if (authzid)
+ authzidlen = strlen (authzid);
- p = gsasl_property_get (sctx, GSASL_AUTHID);
- if (!p)
- {
- res = GSASL_NO_AUTHID;
- goto end;
- }
+ if (authid)
+ authidlen = strlen (authid);
+ else
+ return GSASL_NO_AUTHID;
- authid = gsasl_stringprep_nfkc (p, -1);
- if (authid == NULL)
- {
- res = GSASL_UNICODE_NORMALIZATION_ERROR;
- goto end;
- }
- authidlen = strlen (authid);
+ if (password)
+ passwordlen = strlen (password);
+ else
+ return GSASL_NO_PASSWORD;
- p = gsasl_property_get (sctx, GSASL_PASSWORD);
- if (!p)
- {
- res = GSASL_NO_PASSWORD;
- goto end;
- }
+ *output_len = authzidlen + 1 + authidlen + 1 + passwordlen;
+ *output = out = malloc (*output_len);
+ if (!out)
+ return GSASL_MALLOC_ERROR;
- password = gsasl_stringprep_nfkc (p, -1);
- if (password == NULL)
+ if (authzid)
{
- res = GSASL_UNICODE_NORMALIZATION_ERROR;
- goto end;
+ memcpy (out, authzid, authzidlen);
+ out += authzidlen;
}
- passwordlen = strlen (password);
- *output_len = authzidlen + 1 + authidlen + 1 + passwordlen;
- *output = malloc (*output_len);
- if (*output == NULL)
- {
- res = GSASL_MALLOC_ERROR;
- goto end;
- }
+ *out++ = '\0';
- if (authzid)
- memcpy (*output, authzid, authzidlen);
- (*output)[authzidlen] = '\0';
- memcpy (*output + authzidlen + 1, authid, authidlen);
- (*output)[authzidlen + 1 + authidlen] = '\0';
- memcpy (*output + authzidlen + 1 + authidlen + 1, password, passwordlen);
+ memcpy (out, authid, authidlen);
+ out += authidlen;
- res = GSASL_OK;
+ *out++ = '\0';
-end:
- if (authzid)
- free (authzid);
- if (authid)
- free (authid);
- if (password)
- free (password);
+ memcpy (out, password, passwordlen);
- return res;
+ return GSASL_OK;
}