fixed quite some segmentation faults in http-thr.c.

similar fixes must be done on other task implementations such as http-file.c
This commit is contained in:
2023-01-11 23:59:41 +09:00
parent 529363913f
commit 97133f8c12
76 changed files with 2372 additions and 2167 deletions

View File

@@ -29,7 +29,7 @@
#include "hio-opt.h"
#include "hio-utl.h"
/*
/*
* hio_getopt is based on BSD getopt.
* --------------------------------------------------------------------------
*
@@ -73,18 +73,18 @@ xci_t xgetopt (int argc, xch_t* const* argv, xopt_t* opt)
opt->arg = HIO_NULL;
opt->lngopt = HIO_NULL;
if (opt->cur == HIO_NULL)
if (opt->cur == HIO_NULL)
{
opt->cur = XEMSG;
opt->ind = 1;
}
if (*opt->cur == '\0')
if (*opt->cur == '\0')
{
/* update scanning pointer */
if (opt->ind >= argc || *(opt->cur = argv[opt->ind]) != '-')
if (opt->ind >= argc || *(opt->cur = argv[opt->ind]) != '-')
{
/* All arguments have been processed or the current
/* All arguments have been processed or the current
* argument doesn't start with a dash */
opt->cur = XEMSG;
return XCI_EOF;
@@ -125,7 +125,7 @@ xci_t xgetopt (int argc, xch_t* const* argv, xopt_t* opt)
while (*end != '\0' && *end != '=') end++;
for (o = opt->lng; o->str; o++)
for (o = opt->lng; o->str; o++)
{
const xch_t* str = o->str;
@@ -149,10 +149,10 @@ xci_t xgetopt (int argc, xch_t* const* argv, xopt_t* opt)
}
else if (opt->arg == HIO_NULL)
{
/* check if it has a remaining argument
/* check if it has a remaining argument
* available */
if (argc <= ++opt->ind) return BADARG;
/* If so, the next available argument is
if (argc <= ++opt->ind) return BADARG;
/* If so, the next available argument is
* taken to be an option argument */
opt->arg = argv[opt->ind];
}
@@ -162,12 +162,12 @@ xci_t xgetopt (int argc, xch_t* const* argv, xopt_t* opt)
}
/*if (*end == HIO_T('=')) *end = HIO_T('\0');*/
opt->lngopt = opt->cur;
opt->lngopt = opt->cur;
return BADCH;
}
if ((opt->opt = *opt->cur++) == ':' ||
(oli = xfindcharincstr(opt->str, opt->opt)) == HIO_NULL)
(oli = xfindcharincstr(opt->str, opt->opt)) == HIO_NULL)
{
/*
* if the user didn't specify '-' as an option,
@@ -178,21 +178,21 @@ xci_t xgetopt (int argc, xch_t* const* argv, xopt_t* opt)
return BADCH;
}
if (*++oli != ':')
if (*++oli != ':')
{
/* don't need argument */
if (*opt->cur == '\0') opt->ind++;
}
else
else
{
/* need an argument */
if (*opt->cur != '\0')
if (*opt->cur != '\0')
{
/* no white space */
opt->arg = opt->cur;
}
else if (argc <= ++opt->ind)
else if (argc <= ++opt->ind)
{
/* no arg */
opt->cur = XEMSG;