int *size;
{
char *fromserver;
+ char *end_ptr;
if (server->in_multi)
{
return (-1);
}
- *count = atoi (&fromserver[4]);
+ errno = 0;
+ *count = strtol (&fromserver[4], &end_ptr, 10);
+ /* Check validity of string-to-integer conversion. */
+ if (fromserver[4] == 0 || *end_ptr != 0 || errno)
+ {
+ strcpy (pop_error, "Unexpected response from POP server in pop_stat");
+ pop_trash (server);
+ return (-1);
+ }
fromserver = index (&fromserver[4], ' ');
if (! fromserver)
return (-1);
}
- *size = atoi (fromserver + 1);
+ errno = 0;
+ *size = strtol (fromserver + 1, &end_ptr, 10);
+ if (*(fromserver + 1) == 0 || *end_ptr != 0 || errno)
+ {
+ strcpy (pop_error, "Unexpected response from POP server in pop_stat");
+ pop_trash (server);
+ return (-1);
+ }
return (0);
}
}
else
{
- return (atoi (&fromserver[4]));
+ char *end_ptr;
+ int count;
+ errno = 0;
+ count = strtol (&fromserver[4], &end_ptr, 10);
+ if (fromserver[4] == 0 || *end_ptr != 0 || errno)
+ {
+ strcpy (pop_error, "Unexpected response from server in pop_last");
+ pop_trash (server);
+ return (-1);
+ }
+ return count;
}
}