gsasl-commit
[Top][All Lists]
Advanced

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

CVS gsasl/lib/digest-md5


From: gsasl-commit
Subject: CVS gsasl/lib/digest-md5
Date: Sun, 19 Dec 2004 09:23:39 +0100

Update of /home/cvs/gsasl/lib/digest-md5
In directory dopio:/tmp/cvs-serv443

Modified Files:
        test-parser.c parser.h parser.c 
Log Message:
Use string length indicator in parser API.


--- /home/cvs/gsasl/lib/digest-md5/test-parser.c        2004/12/19 05:36:54     
1.6
+++ /home/cvs/gsasl/lib/digest-md5/test-parser.c        2004/12/19 08:23:38     
1.7
@@ -40,7 +40,7 @@
     char *token = "nonce=4711, foo=bar, algorithm=md5-sess";
 
     printf ("challenge `%s': ", token);
-    rc = digest_md5_parse_challenge (token, &c);
+    rc = digest_md5_parse_challenge (token, 0, &c);
     if (rc != 0)
       abort ();
     printf ("nonce `%s': %s", c.nonce,
@@ -57,7 +57,7 @@
     char *token = "qop=\"auth, auth-conf\", nonce=42, algorithm=md5-sess";
 
     printf ("challenge `%s': ", token);
-    rc = digest_md5_parse_challenge (token, &c);
+    rc = digest_md5_parse_challenge (token, 0, &c);
     if (rc == 0)
       abort ();
     printf ("PASS\n");
@@ -67,7 +67,7 @@
     char *token = "cipher=\"des\", nonce=42, algorithm=md5-sess";
 
     printf ("challenge `%s': ", token);
-    rc = digest_md5_parse_challenge (token, &c);
+    rc = digest_md5_parse_challenge (token, 0, &c);
     if (rc == 0)
       abort ();
     printf ("PASS\n");
@@ -78,7 +78,7 @@
       "cipher=\"des\"";
 
     printf ("challenge `%s': ", token);
-    rc = digest_md5_parse_challenge (token, &c);
+    rc = digest_md5_parse_challenge (token, 0, &c);
     if (rc != 0)
       abort ();
     printf ("qop %02x ciphers %02x: %s\n", c.qops, c.ciphers,
@@ -94,7 +94,7 @@
     char *token = "bar=foo, foo=bar";
 
     printf ("challenge `%s': ", token);
-    rc = digest_md5_parse_challenge (token, &c);
+    rc = digest_md5_parse_challenge (token, 0, &c);
     if (rc == 0)
       abort ();
     printf ("PASS\n");
@@ -104,7 +104,7 @@
     char *token = "realm=foo, realm=bar, nonce=42, algorithm=md5-sess";
 
     printf ("challenge `%s': ", token);
-    rc = digest_md5_parse_challenge (token, &c);
+    rc = digest_md5_parse_challenge (token, 0, &c);
     if (rc != 0)
       abort ();
     if (c.nrealms != 2)
@@ -123,7 +123,7 @@
     char *token = "bar=foo, foo=bar";
 
     printf ("response `%s': ", token);
-    rc = digest_md5_parse_response (token, &r);
+    rc = digest_md5_parse_response (token, 0, &r);
     if (rc == 0)
       abort ();
     printf ("PASS\n");
@@ -134,7 +134,7 @@
       "digest-uri=foo, response=01234567890123456789012345678901";
 
     printf ("response `%s': ", token);
-    rc = digest_md5_parse_response (token, &r);
+    rc = digest_md5_parse_response (token, 0, &r);
     if (rc != 0)
       abort ();
     printf ("username `%s', nonce `%s', cnonce `%s',"
@@ -153,7 +153,7 @@
     char *token = "rspauth=\"4711\"";
 
     printf ("finish `%s': ", token);
-    rc = digest_md5_parse_finish (token, &f);
+    rc = digest_md5_parse_finish (token, 0, &f);
     if (rc != 0)
       abort ();
     printf ("`%s'? %s\n", f.rspauth,
@@ -164,7 +164,7 @@
     char *token = "bar=foo, foo=bar";
 
     printf ("finish `%s': ", token);
-    rc = digest_md5_parse_finish (token, &f);
+    rc = digest_md5_parse_finish (token, 0, &f);
     if (rc == 0)
       abort ();
     printf ("invalid? PASS\n", token);
--- /home/cvs/gsasl/lib/digest-md5/parser.h     2004/12/19 03:13:03     1.5
+++ /home/cvs/gsasl/lib/digest-md5/parser.h     2004/12/19 08:23:38     1.6
@@ -30,13 +30,13 @@
                                 const char *const *tokens,
                                 char **valuep);
 
-extern int digest_md5_parse_challenge (const char *challenge,
+extern int digest_md5_parse_challenge (const char *challenge, size_t len,
                                       digest_md5_challenge *out);
 
-extern int digest_md5_parse_response (const char *response,
+extern int digest_md5_parse_response (const char *response, size_t len,
                                      digest_md5_response *out);
 
-extern int digest_md5_parse_finish (const char *finish,
+extern int digest_md5_parse_finish (const char *finish, size_t len,
                                    digest_md5_finish *out);
 
 #endif /* DIGEST_MD5_PARSER_H */
--- /home/cvs/gsasl/lib/digest-md5/parser.c     2004/12/19 05:35:49     1.10
+++ /home/cvs/gsasl/lib/digest-md5/parser.c     2004/12/19 08:23:38     1.11
@@ -542,6 +542,8 @@
        if (out->rspauth)
          return -1;
        out->rspauth = strdup (value);
+       if (!out->rspauth)
+         return -1;
        break;
 
       default:
@@ -557,14 +559,19 @@
 }
 
 int
-digest_md5_parse_challenge (const char *challenge, digest_md5_challenge *out)
+digest_md5_parse_challenge (const char *challenge, size_t len,
+                           digest_md5_challenge *out)
 {
-  char *subopts = strdup (challenge);
+  size_t inlen = len ? len : strlen (challenge);
+  char *subopts = malloc (inlen + 1);
   int rc;
 
   if (!subopts)
     return -1;
 
+  memcpy (subopts, challenge, inlen);
+  subopts[inlen] = '\0';
+
   rc = parse_challenge (subopts, out);
 
   free (subopts);
@@ -573,14 +580,19 @@
 }
 
 int
-digest_md5_parse_response (const char *response, digest_md5_response *out)
+digest_md5_parse_response (const char *response, size_t len,
+                          digest_md5_response *out)
 {
-  char *subopts = strdup (response);
+  size_t inlen = len ? len : strlen (response);
+  char *subopts = malloc (inlen + 1);
   int rc;
 
   if (!subopts)
     return -1;
 
+  memcpy (subopts, response, inlen);
+  subopts[inlen] = '\0';
+
   rc = parse_response (subopts, out);
 
   free (subopts);
@@ -589,14 +601,19 @@
 }
 
 int
-digest_md5_parse_finish (const char *finish, digest_md5_finish *out)
+digest_md5_parse_finish (const char *finish, size_t len,
+                        digest_md5_finish *out)
 {
-  char *subopts = strdup (finish);
+  size_t inlen = len ? len : strlen (finish);
+  char *subopts = malloc (inlen + 1);
   int rc;
 
   if (!subopts)
     return -1;
 
+  memcpy (subopts, finish, inlen);
+  subopts[inlen] = '\0';
+
   rc = parse_finish (subopts, out);
 
   free (subopts);





reply via email to

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