gsasl-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVS gsasl/lib/src


From: gsasl-commit
Subject: CVS gsasl/lib/src
Date: Sat, 27 Nov 2004 04:28:45 +0100

Update of /home/cvs/gsasl/lib/src
In directory dopio:/tmp/cvs-serv4814

Modified Files:
        xstep.c 
Log Message:
Use new base64 API.


--- /home/cvs/gsasl/lib/src/xstep.c     2004/10/31 16:02:29     1.7
+++ /home/cvs/gsasl/lib/src/xstep.c     2004/11/27 03:28:45     1.8
@@ -87,58 +87,29 @@
 int
 gsasl_step64 (Gsasl_session * sctx, const char *b64input, char **b64output)
 {
-  size_t input_len, output_len;
-  char *input, *output;
+  size_t input_len = 0, output_len = 0;
+  char *input = NULL, *output = NULL;
   int res;
 
-  if (b64input && strlen (b64input) > 0)
+  if (b64input)
     {
-      int len;
-
-      input_len = strlen (b64input) + 1;
-      input = (char *) malloc (input_len);
-      if (input == NULL)
-       return GSASL_MALLOC_ERROR;
-
-      len = gsasl_base64_decode (b64input, input, input_len);
-      if (len == -1)
-       {
-         free (input);
-         return GSASL_BASE64_ERROR;
-       }
-      input_len = (size_t) len;
-    }
-  else
-    {
-      input = NULL;
-      input_len = 0;
+      res = gsasl_base64_from (b64input, strlen (b64input),
+                              &input, &input_len);
+      if (res != GSASL_OK)
+       return GSASL_BASE64_ERROR;
     }
 
   res = gsasl_step (sctx, input, input_len, &output, &output_len);
-
   if (res == GSASL_OK || res == GSASL_NEEDS_MORE)
     {
-      size_t allen = output_len * 4 / 3 + 4;   /* XXX ? */
-      int len;
-
-      *b64output = malloc (allen);
-      if (*b64output == NULL)
-       {
-         if (input != NULL)
-           free (input);
-         if (output != NULL)
-           free (output);
-         return GSASL_MALLOC_ERROR;
-       }
-
-      len = gsasl_base64_encode (output, output_len, *b64output, allen);
-      if (len == -1)
+      res = gsasl_base64_to (output, output_len, b64output, NULL);
+      if (res != GSASL_OK)
        {
          if (input != NULL)
            free (input);
          if (output != NULL)
            free (output);
-         return GSASL_BASE64_ERROR;
+         return res;
        }
 
       if (output != NULL)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]