Fix order of parameters in wildcard call.
authorMargaret Wasserman <margaret@moonshot-proxy>
Tue, 9 Jul 2013 22:50:56 +0000 (18:50 -0400)
committerMargaret Wasserman <margaret@moonshot-proxy>
Tue, 9 Jul 2013 22:50:56 +0000 (18:50 -0400)
common/tr_filter.c
tr/tr_main.c

index fd3171a..adcef7f 100644 (file)
@@ -46,16 +46,20 @@ int tr_prefix_wildcard_match (char *str, char *wc_str) {
   if ((!str) || (!wc_str))
     return 0;
 
-  fprintf(stderr, "tr_prefix_wildcard_match: str = %s, wc_str = %s\n", str, wc_str);
+  len = strlen(str);
+  if (0 == (wc_len = strlen(wc_str)))
+    return 0;
 
   /* TBD -- skip leading white space? */
-  if ('*' == wc_str[0])
+  if ('*' == wc_str[0]) {
     wc_post = &(wc_str[1]);
+    wc_len--;
+  }
 
-  len = strlen(str);
-  wc_len = strlen(wc_post);
-
-  if (!strcmp(&(str[len-wc_len]), wc_post)) {
+  if (wc_len > len)
+    return 0;
+  
+  if (0 == strcmp(&(str[len-wc_len]), wc_post)) {
     return 1;
   }
   else
index 0e659df..c71d724 100644 (file)
@@ -112,8 +112,7 @@ static int tr_tids_req_handler (TIDS_INSTANCE *tids,
     return -1;
   }
 
-  if (!tr_prefix_wildcard_match(((TR_INSTANCE *)tr)->rp_gss->rp_match->buf, 
-                               orig_req->rp_realm->buf)) {
+  if (!tr_prefix_wildcard_match(orig_req->rp_realm->buf, ((TR_INSTANCE *)tr)->rp_gss->rp_match->buf)) { 
     fprintf(stderr, "tr_tids_req_handler: RP realm (%s) does not match RP Realm filter for GSS name (%s)\n", orig_req->rp_realm->buf, ((TR_INSTANCE *)tr)->rp_gss->rp_match->buf);
     tids_send_err_response(tids, orig_req, "RP Realm filter error");
     return -1;
@@ -223,7 +222,7 @@ static int tr_tids_gss_handler(gss_name_t client_name, TR_NAME *gss_name,
   
   /* look up the RP client matching the GSS name */
   if ((NULL == (rp = tr_rp_client_lookup(tr, gss_name)))) {
-    fprintf(stderr, "tr_tids_gss_handler: Unknown GSS name %s", gss_name->buf);
+    fprintf(stderr, "tr_tids_gss_handler: Unknown GSS name %s\n", gss_name->buf);
     return -1;
   }