]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/openid/serv_openid_rp.c
use the gnu format string checker for CtdlLogPrintf; fix associated new warnings...
[citadel.git] / citadel / modules / openid / serv_openid_rp.c
index 384e2b6e08d8cfaf6931f36f562f975ee91e4a34..aee397cad8565d4411fe76d63e5a9bdecac0ec17 100644 (file)
@@ -1,23 +1,21 @@
 /*
- * $Id$
- *
  * This is an implementation of OpenID 1.1 Relying Party support, in stateless mode.
  *
- * Copyright (c) 2007-2009 by the citadel.org team
+ * Copyright (c) 2007-2010 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -127,11 +125,11 @@ int attach_openid(struct ctdluser *who, StrBuf *claimed_id)
                cdb_free(cdboi);
 
                if (fetched_usernum == who->usernum) {
-                       CtdlLogPrintf(CTDL_INFO, "%s already associated; no action is taken\n", claimed_id);
+                       CtdlLogPrintf(CTDL_INFO, "%s already associated; no action is taken\n", ChrPtr(claimed_id));
                        return(0);
                }
                else {
-                       CtdlLogPrintf(CTDL_INFO, "%s already belongs to another user\n", claimed_id);
+                       CtdlLogPrintf(CTDL_INFO, "%s already belongs to another user\n", ChrPtr(claimed_id));
                        return(3);
                }
        }
@@ -190,7 +188,7 @@ void openid_purge(struct ctdluser *usbuf) {
        HashPos = GetNewHashPos(keys, 0);
        while (GetNextHashPos(keys, HashPos, &len, &Key, &Value)!=0)
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Deleting associated OpenID <%s>\n", Value);
+               CtdlLogPrintf(CTDL_DEBUG, "Deleting associated OpenID <%s>\n", (char*)Value);
                cdb_delete(CDB_OPENID, Value, strlen(Value));
                /* note: don't free(Value) -- deleting the hash list will handle this for us */
        }
@@ -503,7 +501,7 @@ void extract_link(StrBuf *target_buf, const char *rel, long repllen, StrBuf *sou
        ptr = ChrPtr(source_buf);
 
        FlushStrBuf(target_buf);
-       while (ptr = bmstrcasestr(ptr, "<link"), ptr != NULL) {
+       while (ptr = cbmstrcasestr(ptr, "<link"), ptr != NULL) {
 
                link_tag_start = ptr;
                link_tag_end = strchr(ptr, '>');
@@ -512,7 +510,7 @@ void extract_link(StrBuf *target_buf, const char *rel, long repllen, StrBuf *sou
                for (i=0; i < 1; i++ ){
                        len = link_tag_end - link_tag_start;
 
-                       rel_start = bmstrcasestr(link_tag_start, "rel=");
+                       rel_start = cbmstrcasestr(link_tag_start, "rel=");
                        if ((rel_start == NULL) ||
                            (rel_start > link_tag_end)) 
                                continue;
@@ -530,7 +528,7 @@ void extract_link(StrBuf *target_buf, const char *rel, long repllen, StrBuf *sou
                        if (strncasecmp(rel, rel_start, repllen)!= 0)
                                continue; /* didn't match? never mind... */
                        
-                       href_start = bmstrcasestr(link_tag_start, "href=");
+                       href_start = cbmstrcasestr(link_tag_start, "href=");
                        if ((href_start == NULL) || 
                            (href_start >= link_tag_end)) 
                                continue;
@@ -590,7 +588,12 @@ int fetch_http(StrBuf *url, StrBuf **target_buf)
 #endif
        curl_easy_setopt(curl, CURLOPT_USERAGENT, CITADEL);
        curl_easy_setopt(curl, CURLOPT_TIMEOUT, 180);           /* die after 180 seconds */
-       if (!IsEmptyStr(config.c_ip_addr)) {
+       if (
+               (!IsEmptyStr(config.c_ip_addr))
+               && (strcmp(config.c_ip_addr, "*"))
+               && (strcmp(config.c_ip_addr, "::"))
+               && (strcmp(config.c_ip_addr, "0.0.0.0"))
+       ) {
                curl_easy_setopt(curl, CURLOPT_INTERFACE, config.c_ip_addr);
        }
        res = curl_easy_perform(curl);
@@ -831,7 +834,12 @@ void cmd_oidf(char *argbuf) {
 #endif
        curl_easy_setopt(curl, CURLOPT_USERAGENT, CITADEL);
        curl_easy_setopt(curl, CURLOPT_TIMEOUT, 180);           /* die after 180 seconds */
-       if (!IsEmptyStr(config.c_ip_addr)) {
+       if (
+               (!IsEmptyStr(config.c_ip_addr))
+               && (strcmp(config.c_ip_addr, "*"))
+               && (strcmp(config.c_ip_addr, "::"))
+               && (strcmp(config.c_ip_addr, "0.0.0.0"))
+       ) {
                curl_easy_setopt(curl, CURLOPT_INTERFACE, config.c_ip_addr);
        }
 
@@ -842,7 +850,7 @@ void cmd_oidf(char *argbuf) {
        curl_easy_cleanup(curl);
        curl_formfree(formpost);
 
-       if (bmstrcasestr(ChrPtr(ReplyBuf), "is_valid:true")) {
+       if (cbmstrcasestr(ChrPtr(ReplyBuf), "is_valid:true")) {
                oiddata->verified = 1;
        }
        FreeStrBuf(&ReplyBuf);
@@ -959,5 +967,5 @@ CTDL_MODULE_INIT(openid_rp)
        }
 
        /* return our Subversion id for the Log */
-       return "$Id$";
+       return "openid_rp";
 }