hls: fix handling of strol() overflows

This commit is contained in:
Alessandro Decina 2011-05-15 10:00:44 +02:00
parent 9b23e213cb
commit adc0817b2a

View file

@ -104,21 +104,29 @@ static gboolean
int_from_string (gchar * ptr, gchar ** endptr, gint * val)
{
gchar *end;
glong ret;
g_return_val_if_fail (ptr != NULL, FALSE);
g_return_val_if_fail (val != NULL, FALSE);
errno = 0;
*val = strtol (ptr, &end, 10);
if ((errno == ERANGE && (*val == LONG_MAX || *val == LONG_MIN))
|| (errno != 0 && *val == 0)) {
ret = strtol (ptr, &end, 10);
if ((errno == ERANGE && (ret == LONG_MAX || ret == LONG_MIN))
|| (errno != 0 && ret == 0)) {
GST_WARNING ("%s", g_strerror (errno));
return FALSE;
}
if (ret > G_MAXINT) {
GST_WARNING ("%s", g_strerror (ERANGE));
return FALSE;
}
if (endptr)
*endptr = end;
*val = (gint) ret;
return end != ptr;
}