]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Thu Jan 8 13:50:53 CST 2009 Pekka Pessi <first.last@nokia.com>
authorMichael Jerris <mike@jerris.com>
Wed, 11 Feb 2009 16:47:44 +0000 (16:47 +0000)
committerMichael Jerris <mike@jerris.com>
Wed, 11 Feb 2009 16:47:44 +0000 (16:47 +0000)
  * iptsec: using <sofia-sip/su_string.h> functions

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11796 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/sofia-sip/.update
libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client_ntlm.c
libs/sofia-sip/libsofia-sip-ua/iptsec/auth_common.c
libs/sofia-sip/libsofia-sip-ua/iptsec/auth_module.c
libs/sofia-sip/libsofia-sip-ua/iptsec/auth_ntlm.c
libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin.c
libs/sofia-sip/libsofia-sip-ua/iptsec/auth_plugin_ntlm.c
libs/sofia-sip/libsofia-sip-ua/iptsec/test_auth_digest.c

index 40bc29e9193ebeb6a8abad7969cc496314344e75..9243f4bb9983b9cc90dbf9dbe1cf0956702854d7 100644 (file)
@@ -1 +1 @@
-Wed Feb 11 10:47:06 CST 2009
+Wed Feb 11 10:47:34 CST 2009
index f00e569cb90a7b23c54c5a6e5f1d151dc90760aa..d536ce02c94e4ebd2eb9a15c353c5e84e6ed23b1 100644 (file)
@@ -47,7 +47,7 @@
 
 #include <sofia-sip/base64.h>
 #include <sofia-sip/su_uniqueid.h>
-#include <sofia-sip/string0.h>
+#include <sofia-sip/su_string.h>
 
 #include <sofia-sip/su_debug.h>
 
@@ -166,9 +166,9 @@ int ca_challenge(auth_client_t *ca,
   if (!ca || !ch)
     return -1;
 
-  if (strcasecmp(ca->ca_scheme, scheme))
+  if (!su_casematch(ca->ca_scheme, scheme))
     return 0;
-  if (strcmp(ca->ca_realm, realm))
+  if (!su_strmatch(ca->ca_realm, realm))
     return 0;
 
   if (ca->ca_credential_class &&
@@ -390,13 +390,13 @@ int ca_credentials(auth_client_t *ca,
   if (!ca || !ca->ca_scheme || !ca->ca_realm)
     return -1;
 
-  if ((scheme != NULL && strcasecmp(scheme, ca->ca_scheme)) ||
-      (realm != NULL && strcmp(realm, ca->ca_realm)))
+  if ((scheme != NULL && !su_casematch(scheme, ca->ca_scheme)) ||
+      (realm != NULL && !su_strmatch(realm, ca->ca_realm)))
     return 0;
 
   old_user = ca->ca_user, old_pass = ca->ca_pass;
 
-  if (str0cmp(user, old_user) == 0 && str0cmp(pass, old_pass) == 0)
+  if (su_strmatch(user, old_user) && su_strmatch(pass, old_pass))
     return 0;
 
   new_user = su_strdup(ca->ca_home, user);
@@ -440,14 +440,14 @@ int auc_copy_credentials(auth_client_t **dst,
        continue;
       if (AUTH_CLIENT_IS_EXTENDED(ca) && ca->ca_clear)
        continue;
-      if (!ca->ca_scheme[0] || strcasecmp(ca->ca_scheme, d->ca_scheme))
+      if (!ca->ca_scheme[0] || !su_casematch(ca->ca_scheme, d->ca_scheme))
        continue;
-      if (!ca->ca_realm[0] || strcmp(ca->ca_realm, d->ca_realm))
+      if (!ca->ca_realm || !su_strmatch(ca->ca_realm, d->ca_realm))
        continue;
 
       if (!(AUTH_CLIENT_IS_EXTENDED(d) && d->ca_clear) &&
-         d->ca_user && strcmp(d->ca_user, ca->ca_user) == 0 &&
-         d->ca_pass && strcmp(d->ca_pass, ca->ca_pass) == 0) {
+         su_strmatch(d->ca_user, ca->ca_user) &&
+         su_strmatch(d->ca_pass, ca->ca_pass)) {
        retval++;
        break;
       }
@@ -497,8 +497,8 @@ int auc_clear_credentials(auth_client_t **auc_list,
     if (!AUTH_CLIENT_IS_EXTENDED(ca))
       continue;
 
-    if ((scheme != NULL && strcasecmp(scheme, ca->ca_scheme)) ||
-       (realm != NULL && strcmp(realm, ca->ca_realm)))
+    if ((scheme != NULL && !su_casematch(scheme, ca->ca_scheme)) ||
+       (realm != NULL && !su_strmatch(realm, ca->ca_realm)))
       continue;
 
     match = ca->ca_auc->auc_clear(*auc_list);
@@ -990,7 +990,7 @@ int auc_register_plugin(auth_client_plugin_t const *plugin)
 
   for (i = 0; i < MAX_AUC; i++) {
     if (ca_plugins[i] == NULL ||
-       strcmp(plugin->auc_name, ca_plugins[i]->auc_name) == 0) {
+       su_strmatch(plugin->auc_name, ca_plugins[i]->auc_name) == 0) {
       ca_plugins[i] = plugin;
       return 0;
     }
@@ -1018,7 +1018,7 @@ auth_client_t *ca_create(su_home_t *home,
 
   for (i = 0; i < MAX_AUC; i++) {
     auc = ca_plugins[i];
-    if (!auc || strcasecmp(auc->auc_name, scheme) == 0)
+    if (!auc || su_casematch(auc->auc_name, scheme))
       break;
   }
 
index 3fe6e076dccd19364e87f708f13c9edc8da831bf..8b2b155f11104dbd61906e78fefb879c49efcb61 100644 (file)
@@ -44,7 +44,7 @@
 
 #include <sofia-sip/base64.h>
 #include <sofia-sip/su_uniqueid.h>
-#include <sofia-sip/string0.h>
+#include <sofia-sip/su_string.h>
 
 #include <sofia-sip/su_debug.h>
 
index ad40282d35d320b3f097a49323afce6aa6e610e8..416d1e92529e4e932ae3814032495cb1e371872d 100644 (file)
 
 #include "sofia-sip/auth_common.h"
 #include "sofia-sip/msg_header.h"
+#include <sofia-sip/su_string.h>
 
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
 #include <assert.h>
 
-#if !HAVE_STRCASESTR
-char *strcasestr(char const *haystack, char const *needle);
-#endif
-
 su_inline int has_token(char const *qstring, char const *token);
 
 /**
@@ -92,12 +89,12 @@ issize_t auth_get_params(su_home_t *home,
         if expected is found in parameter value,
         return non-NULL pointer in *return_value */
       for (j = 0; (p = params[j++]);) {
-       if (strcasecmp(p, fmt) == 0) {
+       if (su_casematch(p, fmt)) {
          /* Matched the whole parameter with fmt name=expected */
          value = p;
          break;
        }
-       else if (strncasecmp(p, fmt, namelen) ||
+       else if (!su_casenmatch(p, fmt, namelen) ||
                 p[namelen] != '=')
          continue;
 
@@ -109,7 +106,7 @@ issize_t auth_get_params(su_home_t *home,
          value = p;
          break;
        }
-       else if (strcasecmp(p, expected) == 0) {
+       else if (su_casematch(p, expected)) {
          /* Parameter value matches with extected value
           * e.g., qop=auth matches qop=auth */
          value = p;
@@ -120,7 +117,7 @@ issize_t auth_get_params(su_home_t *home,
     else {
       /* format is name= , return unquoted parameter value after = */
       for (j = 0; (p = params[j++]);) {
-       if (strncasecmp(p, fmt, len))
+       if (!su_casenmatch(p, fmt, len))
          continue;
 
        if (p[len] == '"')
@@ -169,7 +166,8 @@ su_inline int has_token(char const *qstring, char const *token)
   size_t n = strlen(token);
   char const *q;
 
-  q = strcasestr(qstring, token);
+  q = su_strcasestr(qstring, token);
+
   return (q &&
          (q[n] == 0 || strchr("\", \t", q[n])) &&
          (q == qstring || strchr("\", \t", q[-1])));
index cd37c3aafe91173bd6dd818de0d160c849d6904b..830603f16997005d679aa5982f7acbe186af3028 100644 (file)
@@ -61,6 +61,7 @@ static char const __func__[] = "auth_mod";
 
 #include <sofia-sip/su_wait.h>
 #include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_string.h>
 #include <sofia-sip/su_tagarg.h>
 
 #include <sofia-sip/base64.h>
@@ -181,7 +182,7 @@ int auth_init_default(auth_mod_t *am,
   am->am_fake = fake;
   am->am_remote = url_hdup(am->am_home, (url_t *)remote);
   am->am_algorithm = algorithm ? su_strdup(am->am_home, algorithm) : "MD5";
-  am->am_nextnonce = !algorithm || strcasecmp(algorithm, "MD5") == 0;
+  am->am_nextnonce = !algorithm || su_casematch(algorithm, "MD5");
   if (next_expires == 0)
     am->am_nextnonce = 0;
   am->am_qop = su_strdup(am->am_home, qop);
@@ -694,11 +695,11 @@ void auth_check_digest(auth_mod_t *am,
       /* Check for qop */
       (ar->ar_qop &&
        ((ar->ar_auth &&
-        strcasecmp(ar->ar_qop, "auth") &&
-        strcasecmp(ar->ar_qop, "\"auth\"")) ||
+        !su_casematch(ar->ar_qop, "auth") &&
+        !su_casematch(ar->ar_qop, "\"auth\"")) ||
        (ar->ar_auth_int &&
-        strcasecmp(ar->ar_qop, "auth-int") &&
-        strcasecmp(ar->ar_qop, "\"auth-int\"")))
+        !su_casematch(ar->ar_qop, "auth-int") &&
+        !su_casematch(ar->ar_qop, "\"auth-int\"")))
        && (phrase = PA "has invalid qop"))) {
     assert(phrase);
     SU_DEBUG_5(("auth_method_digest: 400 %s\n", phrase));
@@ -1249,7 +1250,7 @@ msg_auth_t *auth_mod_credentials(msg_auth_t *auth,
   char const *arealm;
 
   for (;auth; auth = auth->au_next) {
-    if (strcasecmp(auth->au_scheme, scheme))
+    if (!su_casematch(auth->au_scheme, scheme))
       continue;
 
     if (!realm)
@@ -1290,7 +1291,7 @@ msg_auth_t *auth_digest_credentials(msg_auth_t *auth,
   char const *arealm, *aopaque;
 
   for (;auth; auth = auth->au_next) {
-    if (strcasecmp(auth->au_scheme, "Digest"))
+    if (!su_casematch(auth->au_scheme, "Digest"))
       continue;
 
     if (realm) {
index b0b097236fb1affd67bd6786c1b7f73a2a507d27..a2c659585a747494be546eacdac986f7de2a6204 100644 (file)
@@ -91,7 +91,7 @@ issize_t auth_ntlm_challenge_get(su_home_t *home,
   if (n < 0)
     return n;
 
-  if (ac->ac_stale && strcasecmp(ac->ac_stale, "true") != 0)
+  if (ac->ac_stale && !su_casematch(ac->ac_stale, "true"))
     ac->ac_stale = NULL;
 
   ac->ac_md5 = md5 != NULL || ac->ac_algorithm == NULL;
index 3b0324722b002d9d6f6e4eb056f2fb4f7a646a6d..c7db9e19e4d25362c72489a02b0cfb988f531ef4 100644 (file)
@@ -52,6 +52,7 @@ static char const __func__[] = "auth_plugin";
 
 #include <sofia-sip/su_wait.h>
 #include <sofia-sip/su_alloc.h>
+#include <sofia-sip/su_string.h>
 #include <sofia-sip/su_tagarg.h>
 
 #include "sofia-sip/auth_module.h"
@@ -130,16 +131,16 @@ auth_mod_t *auth_mod_create(su_root_t *root,
 
     if (base == NULL)
       ;
-    else if (strcasecmp(base, "Basic") == 0)
+    else if (su_casematch(base, "Basic"))
       bscheme = auth_scheme_basic;
-    else if (strcasecmp(base, "Digest") == 0)
+    else if (su_casematch(base, "Digest"))
       bscheme = auth_scheme_digest;
 
     if (base == NULL || bscheme) {
       int i;
 
       for (i = 0; schemes[i] && i < N; i++) {
-       if (strncasecmp(schemes[i]->asch_method, method, len) == 0 &&
+       if (su_casenmatch(schemes[i]->asch_method, method, len) &&
            schemes[i]->asch_method[len] == 0) {
          am = auth_mod_alloc(schemes[i], ta_tags(ta));
          if (schemes[i]->asch_init(am, bscheme, root, ta_tags(ta)) == -1) {
index 9c11ad25d55eafc79d792820cb304ecfe31a8861..6b8e40f417db714fcbbd007a55a9aa6d095f8e5d 100644 (file)
@@ -170,7 +170,7 @@ msg_auth_t *auth_ntlm_credentials(msg_auth_t *auth,
   char const *agssapidata, *atargetname;
 
   for (;auth; auth = auth_mod_credentials(auth->au_next)) {
-    if (strcasecmp(auth->au_scheme, "NTLM"))
+    if (!su_casematch(auth->au_scheme, "NTLM"))
       continue;
 
     if (gssapidata) {
@@ -224,11 +224,11 @@ void auth_check_ntlm(auth_mod_t *am,
       /* Check for qop */
       (ar->ar_qop &&
        ((ar->ar_auth &&
-        strcasecmp(ar->ar_qop, "auth") &&
-        strcasecmp(ar->ar_qop, "\"auth\"")) ||
+        !su_casematch(ar->ar_qop, "auth") &&
+        !su_casematch(ar->ar_qop, "\"auth\"")) ||
        (ar->ar_auth_int &&
-        strcasecmp(ar->ar_qop, "auth-int") &&
-        strcasecmp(ar->ar_qop, "\"auth-int\"")))
+        !su_casematch(ar->ar_qop, "auth-int") &&
+        !su_casematch(ar->ar_qop, "\"auth-int\"")))
        && (phrase = PA "has invalid qop"))) {
     assert(phrase);
     SU_DEBUG_5(("auth_method_ntlm: 400 %s\n", phrase));
index 523568d2fac5ce2b8c84b0af1bb95f6aa60f83a8..89bcd64c7356261ca0fa1e50b75653ca3defd779 100644 (file)
@@ -73,6 +73,7 @@
 #include <sofia-sip/auth_client.h>
 #include <sofia-sip/msg_header.h>
 #include <sofia-sip/su_wait.h>
+#include <sofia-sip/su_string.h>
 
 int tstflags;
 char *argv0;
@@ -349,8 +350,11 @@ Authorization: Digest       username="Mufasa",
     TEST_SIZE(auth_digest_challenge_get(home, ac, pa->au_params), 6);
 
     TEST0(pz = sip_proxy_authorization_make(home, cred));
-    TEST_SIZE(auth_digest_response_get(home, ar, pz->au_params), 8);
 
+    {
+    size_t n = auth_digest_response_get(home, ar, pz->au_params);
+    TEST_SIZE(n, 8);
+    }
     ar->ar_md5 = ac->ac_md5 || ac->ac_algorithm == NULL;
 
     TEST(auth_digest_sessionkey(ar, sessionkey, "test1"), 0);
@@ -702,7 +706,7 @@ int test_digest_client()
 
       if (au->au_params)
        for (i = 0; au->au_params[i]; i++) {
-         if (strncasecmp(au->au_params[i], "realm=", 6) == 0)
+         if (su_casenmatch(au->au_params[i], "realm=", 6))
            continue;
          equal = strchr(au->au_params[i], '=');
          if (equal)