fixed a wrong data type of a parameter passed to ioctl.

fixed the segfault when no host configuration is in the configuration file
This commit is contained in:
hyung-hwan 2013-04-02 14:28:33 +00:00
parent 15924c72cd
commit 010b5fb9c0
9 changed files with 3420 additions and 3380 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -80,8 +80,12 @@
<if cond="ENABLE_DLL=='1'">shared</if> <if cond="ENABLE_DLL=='1'">shared</if>
<if cond="ENABLE_DLL=='0'">static</if> <if cond="ENABLE_DLL=='0'">static</if>
</set> </set>
<set var="BUILDDIR_TCPV40HDRS">
<if cond="TCPV40HDRS=='on'">-tcpv40hdrs</if>
<if cond="TCPV40HDRS=='off'"></if>
</set>
<set var="BUILDDIR"> <set var="BUILDDIR">
$(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED) $(BUILDDIR_BUILD)-$(BUILDDIR_CHAR)-$(BUILDDIR_SHARED)$(BUILDDIR_TCPV40HDRS)
</set> </set>
<!-- ========================================================= <!-- =========================================================

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -428,34 +428,36 @@ static int query_server (
return 0; return 0;
} }
if (req) if (server_xtn->cfgtab)
{ {
const qse_htre_hdrval_t* hosthdr; if (req && server_xtn->cfgtab)
const qse_mchar_t* host;
const qse_mchar_t* qpath;
qpath = qse_htre_getqpath (req);
hosthdr = qse_htre_getheaderval (req, QSE_MT("Host"));
if (hosthdr)
{ {
const qse_mchar_t* colon; const qse_htre_hdrval_t* hosthdr;
qse_size_t hostlen; const qse_mchar_t* host;
const qse_mchar_t* qpath;
/* take the last host value and search */ qpath = qse_htre_getqpath (req);
while (hosthdr->next) hosthdr = hosthdr->next;
host = hosthdr->ptr;
/* remove :port-number if the host name contains it */ hosthdr = qse_htre_getheaderval (req, QSE_MT("Host"));
colon = qse_mbsrchr(host, QSE_MT(':')); if (hosthdr)
if (colon) hostlen = colon - host; {
else hostlen = qse_mbslen(host); const qse_mchar_t* colon;
qse_size_t hostlen;
loccfg = find_loccfg (httpd, server_xtn->cfgtab, host, hostlen, qpath); /*while (hosthdr->next) hosthdr = hosthdr->next; */
host = hosthdr->ptr;
/* remove :port-number if the host name contains it */
colon = qse_mbsrchr(host, QSE_MT(':'));
if (colon) hostlen = colon - host;
else hostlen = qse_mbslen(host);
loccfg = find_loccfg (httpd, server_xtn->cfgtab, host, hostlen, qpath);
}
if (loccfg == QSE_NULL) loccfg = find_loccfg (httpd, server_xtn->cfgtab, QSE_MT("*"), 1, qpath);
} }
if (loccfg == QSE_NULL) loccfg = find_loccfg (httpd, server_xtn->cfgtab, QSE_MT("*"), 1, qpath); if (loccfg == QSE_NULL) loccfg = find_loccfg (httpd, server_xtn->cfgtab, QSE_MT("*"), 1, QSE_MT("/"));
} }
if (loccfg == QSE_NULL) loccfg = find_loccfg (httpd, server_xtn->cfgtab, QSE_MT("*"), 1, QSE_MT("/"));
if (loccfg == QSE_NULL) loccfg = &httpd_xtn->dflcfg; if (loccfg == QSE_NULL) loccfg = &httpd_xtn->dflcfg;
switch (code) switch (code)
@ -1248,7 +1250,7 @@ static int open_config_file (qse_httpd_t* httpd)
QSE_ASSERT (httpd_xtn->xli == QSE_NULL); QSE_ASSERT (httpd_xtn->xli == QSE_NULL);
httpd_xtn->xli = qse_xli_openstd (0); httpd_xtn->xli = qse_xli_openstd (0);
if ( httpd_xtn->xli == QSE_NULL) if (httpd_xtn->xli == QSE_NULL)
{ {
qse_fprintf (QSE_STDERR, QSE_T("Cannot open xli\n")); qse_fprintf (QSE_STDERR, QSE_T("Cannot open xli\n"));
return -1; return -1;
@ -1689,4 +1691,3 @@ int qse_main (int argc, qse_achar_t* argv[])
return ret; return ret;
} }

View File

@ -377,17 +377,19 @@ qse_mchar_t* qse_fmthttptime (
/* TODO: avoid using snprintf () */ /* TODO: avoid using snprintf () */
#if defined(_MSC_VER) || (defined(__WATCOMC__) && (__WATCOMC__ < 1200)) #if defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1200))
_snprintf (buf, bufsz, # define snprintf _snprintf
#else
snprintf (buf, bufsz,
#endif #endif
snprintf (
buf, bufsz,
QSE_MT("%s, %d %s %d %02d:%02d:%02d GMT"), QSE_MT("%s, %d %s %d %02d:%02d:%02d GMT"),
wday_name[bt.wday].s, wday_name[bt.wday].s,
bt.mday, bt.mday,
mon_name[bt.mon].s, mon_name[bt.mon].s,
bt.year + QSE_BTIME_YEAR_BASE, bt.year + QSE_BTIME_YEAR_BASE,
bt.hour, bt.min, bt.sec); bt.hour, bt.min, bt.sec
);
return buf; return buf;
} }

View File

@ -928,7 +928,7 @@ static int peer_open (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
#elif defined(__OS2__) #elif defined(__OS2__)
cmd = 1; cmd = 1;
if (ioctl(fd, FIONBIO, &cmd, QSE_SIZEOF(cmd)) == -1) goto oops; if (ioctl(fd, FIONBIO, (char*)&cmd, QSE_SIZEOF(cmd)) == -1) goto oops;
if (connect (fd, (struct sockaddr*)&connaddr, connaddrsize) == -1) if (connect (fd, (struct sockaddr*)&connaddr, connaddrsize) == -1)
{ {
@ -937,7 +937,7 @@ static int peer_open (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
} }
cmd = 0; cmd = 0;
if (ioctl(fd, FIONBIO, &cmd, QSE_SIZEOF(cmd)) == -1) goto oops; if (ioctl(fd, FIONBIO, (char*)&cmd, QSE_SIZEOF(cmd)) == -1) goto oops;
#elif defined(__DOS__) #elif defined(__DOS__)