[linux-dvb] Asys P7131 Hybrid: DVB out of range

Trent Piepho xyzzy at speakeasy.org
Thu Sep 6 16:12:02 CEST 2007

On Thu, 6 Sep 2007, Andreas Oberritter wrote:
> Trent Piepho wrote:
> > But, 2147483647 is not a valid DVB-T frequency.  It looks like some random
> > number.
> It's not that random: 2147483647 equals INT_MAX and also LONG_MAX on 32
> bit systems.
> Quoting from the manpage of strtol():
> The strtol() function returns the result of the conversion, unless the
> value would underflow or overflow.  If an  underflow  occurs,  strtol()
> returns  LONG_MIN.   If  an overflow occurs, strtol() returns LONG_MAX.
> In both cases, errno is set to ERANGE.  Precisely the  same  holds  for
> strtoll()  (with  LLONG_MIN  and  LLONG_MAX  instead  of  LONG_MIN  and
> My conclusion: Your channels.conf contains invalid frequency values.
> Tzap uses strtol() to parse those values and returns LONG_MAX.

Very clever, I bet you are right about that!

Previously the frequency range wasn't checked, so something like this could
go undetected.  There wouldn't be any error returned when FE_SET_FRONTEND
was called.  The tuner driver would either reject the value when the tuning
thread tried to set it, or it would program the tuner so some bogus
setting.  Either no signal would be detected, or the frequency would remain
unchanged from whatever it was at before, and so the last channel tuned
might appear, as if it was at 2147483647 Hz.

More information about the linux-dvb mailing list