From: Wilfried Göesgens Date: Sat, 21 Feb 2009 14:12:43 +0000 (+0000) Subject: * check whether serv_info is present before dereferencing its pointer. X-Git-Tag: v7.86~1425 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=228054a071ef16a6450f9a4a39f67852267265fe * check whether serv_info is present before dereferencing its pointer. --- diff --git a/webcit/auth.c b/webcit/auth.c index 0cba72069..a83b98e59 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -536,16 +536,17 @@ void end_webcit_session(void) { */ void do_logout(void) { + wcsession *WCC = WC; char buf[SIZ]; - FlushStrBuf(WC->wc_username); - FlushStrBuf(WC->wc_password); - FlushStrBuf(WC->wc_roomname); - FlushStrBuf(WC->wc_fullname); + FlushStrBuf(WCC->wc_username); + FlushStrBuf(WCC->wc_password); + FlushStrBuf(WCC->wc_roomname); + FlushStrBuf(WCC->wc_fullname); /* FIXME: this is to suppress the iconbar displaying, because we aren't actually logged out yet */ - WC->logged_in = 0; + WCC->logged_in = 0; /** Calling output_headers() this way causes the cookies to be un-set */ output_headers(1, 1, 0, 1, 0, 0); @@ -558,7 +559,7 @@ void do_logout(void) serv_puts("MESG goodbye"); serv_getln(buf, sizeof buf); - if (WC->serv_sock >= 0) { + if (WCC->serv_sock >= 0) { if (buf[0] == '1') { fmout("CENTER"); } else { diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 1513bccb1..d64d83983 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -534,41 +534,65 @@ void tmplput_serv_ip(StrBuf *Target, WCTemplputParams *TP) void tmplput_serv_nodename(StrBuf *Target, WCTemplputParams *TP) { - StrBufAppendTemplate(Target, TP, WC->serv_info->serv_nodename, 0); + wcsession *WCC = WC; + if (WCC->serv_info == NULL) + return; + StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_nodename, 0); } void tmplput_serv_humannode(StrBuf *Target, WCTemplputParams *TP) { - StrBufAppendTemplate(Target, TP, WC->serv_info->serv_humannode, 0); + wcsession *WCC = WC; + if (WCC->serv_info == NULL) + return; + StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_humannode, 0); } void tmplput_serv_fqdn(StrBuf *Target, WCTemplputParams *TP) { - StrBufAppendTemplate(Target, TP, WC->serv_info->serv_fqdn, 0); + wcsession *WCC = WC; + if (WCC->serv_info == NULL) + return; + StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_fqdn, 0); } void tmplput_serv_software(StrBuf *Target, WCTemplputParams *TP) { - StrBufAppendTemplate(Target, TP, WC->serv_info->serv_software, 0); + wcsession *WCC = WC; + if (WCC->serv_info == NULL) + return; + StrBufAppendTemplate(Target, TP, WCC->serv_info->serv_software, 0); } void tmplput_serv_rev_level(StrBuf *Target, WCTemplputParams *TP) { + wcsession *WCC = WC; + if (WCC->serv_info == NULL) + return; StrBufAppendPrintf(Target, "%d.%02d", - WC->serv_info->serv_rev_level / 100, - WC->serv_info->serv_rev_level % 100); + WCC->serv_info->serv_rev_level / 100, + WCC->serv_info->serv_rev_level % 100); } int conditional_serv_newuser_disabled(StrBuf *Target, WCTemplputParams *TP) { - return WC->serv_info->serv_newuser_disabled != 0; + wcsession *WCC = WC; + if (WCC->serv_info == NULL) + return 0; + return WCC->serv_info->serv_newuser_disabled != 0; } int conditional_serv_supports_openid(StrBuf *Target, WCTemplputParams *TP) { - return WC->serv_info->serv_supports_openid != 0; + wcsession *WCC = WC; + if (WCC->serv_info == NULL) + return 0; + return WCC->serv_info->serv_supports_openid != 0; } void tmplput_serv_bbs_city(StrBuf *Target, WCTemplputParams *TP) { + wcsession *WCC = WC; + if (WCC->serv_info == NULL) + return; StrBufAppendTemplate(Target, TP, WC->serv_info->serv_bbs_city, 0); }