Export to GitHub

iperf - issue #92

Don't assume unsigned char. getopt_long returns int not char


Posted on Oct 2, 2013 by Massive Elephant

In src/iperf_api.c iperf_parse_arguments():

Define ch as int not as char. Type char is an unsigned type on ARM architectures. If you assign the return value of getopt_long() to a char type, it'll convert -1 to 255 which will never compare equal to -1.

((ch = getopt_long(argc, argv, "p:f:i:DVJdvsc:ub:t:n:l:P:Rw:B:M:N6S:Zh", longopts, NULL)) != -1)

will be always true because ch is unsigned and therefore never equal to -1.

Comment #1

Posted on Oct 2, 2013 by Massive Elephant

I meant to say "Don't assume signed char".

Comment #2

Posted on Oct 2, 2013 by Happy Bear

This is fixed in the current version.

Status: Fixed

Labels:
Type-Defect Priority-Medium