[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bluetooth-dev] bug in set_local_hostname in bt_if.c



Hi,

the function set_local_hostname contains a little bug that can result
in a never returning function:

The while() loop can be endless, when the local_name only contains invalid characters
(outside ' ' and 'z'). In such cases len and local_name are never increased and the break
condition for the loop is never reached.

Further *local_name++ increases *local_name and not the local_name pointer.

     while (*local_name && len < LOCAL_NAME_LENGTH)
     {
       if (*local_name >= ' ' && *local_name <= 'z')
       {
         buf[len++] = *local_name++;
       }
     }

I think the code should look like this:

     while (*local_name && len < LOCAL_NAME_LENGTH)
     {
       if (*local_name >= ' ' && *local_name <= 'z')
       {
         buf[len++] = *local_name;
       }
       local_name++;	
     }

-- 
-------------------------------------------------------------------------

                             _/_/_/_/   Matthias Fuchs
                            _/_/_/_/   Dipl.-Ing.
                           _/_/_/_/   matthias.fuchs@xxxxxxx.com

       _/_/_/   _/_/_/_/_/_/_/      esd electronic system design gmbh
     _/   _/  _/             _/    Vahrenwalder Str. 207
    _/   _/    _/_/_/   _/   _/   D-30165 Hannover
    _/             _/  _/   _/   Phone: +49-511-37298-0
     _/_/_/_/_/_/_/   _/_/_/    Fax:   +49-511-37298-68

-------------------------------------------------------------------------


-
To unsubscribe from this list: send the line "unsubscribe bluetooth-dev" in
the body of a message to majordomo@xxxxxxx.com