Commit 26856e25 authored by Per Cederqvist's avatar Per Cederqvist

Use strtol instead of atol. (Bug 143).

* src/server/conf-file.c (convert_to_long): New function.
(assign_text_no): Use it instead of using atol.  Check for
overflow.
(assign_conf_no): Ditto.
(assign_int): Ditto.
parent e2ad881d
2006-07-26 Per Cederqvist <ceder@lysator.liu.se>
Use strtol instead of atol. (Bug 143).
* src/server/conf-file.c (convert_to_long): New function.
(assign_text_no): Use it instead of using atol. Check for
overflow.
(assign_conf_no): Ditto.
(assign_int): Ditto.
Log a message when a conference (or person) is deleted.
* src/server/conference.c (delete_conf): Log a message when a
conference is deleted, which includes the name of the conference
......
......@@ -257,19 +257,39 @@ free_config(const struct parameter *par)
}
static Success
convert_to_long(const char *val,
long *res)
{
char *end;
*res = strtol(val, &end, 10);
if (end == val)
return FAILURE;
while (*end == ' ' || *end == '\t') /* Ignore trailing whitespace. */
end++;
if (*end != '\0')
return FAILURE;
return OK;
}
static Success
assign_text_no(const char *val,
const struct parameter *par)
{
int c;
/* FIXME (bug 143): use strtol */
if (val != NULL)
{
c = (unsigned char)*val;
if (!isascii(c) || !isdigit(c))
long res;
if (convert_to_long(val, &res) != OK)
return FAILURE;
*(Text_no*)par->value = res;
/* Check for overflow. */
if (*(Text_no*)par->value != res)
return FAILURE;
*(Text_no*)par->value = atol(val);
}
return OK;
}
......@@ -278,15 +298,18 @@ static Success
assign_conf_no(const char *val,
const struct parameter *par)
{
int c;
/* FIXME (bug 143): use strtol */
if (val != NULL)
{
c = (unsigned char)*val;
if (!isascii(c) || !isdigit(c))
long res;
if (convert_to_long(val, &res) != OK)
return FAILURE;
*(Conf_no*)par->value = res;
/* Check for overflow. */
if (*(Conf_no*)par->value != res)
return FAILURE;
*(Conf_no*)par->value = atol(val);
}
return OK;
}
......@@ -295,15 +318,18 @@ static Success
assign_int(const char *val,
const struct parameter *par)
{
int c;
/* FIXME (bug 143): use strtol */
if (val != NULL)
{
c = (unsigned char)*val;
if ((!isascii(c) || !isdigit(c)) && c != '-')
long res;
if (convert_to_long(val, &res) != OK)
return FAILURE;
*(int*)par->value = res;
/* Check for overflow. */
if (*(int*)par->value != res)
return FAILURE;
*(int*)par->value = atol(val);
}
return OK;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment