On Fri, 12 Jun 2009 12:12:33 +0200, Marcel Holtmann <mar...@holtmann.org>
wrote:
> Hi Aki,
> 
>> Anyway, here it is. Please test; seems to work for me on my N95.
> 
> +static void extract_mcc_mnc(const char *str, char *mcc, char *mnc)
>  {
> -       int num = 0;
> -       unsigned int i;
> -
>         /* Three digit country code */
> -       for (i = 0; i < 3; i++)
> -               num = num * 10 + (int)(str[i] - '0');
> -
> -       *mcc = num;
> -
> -       num = 0;
> +       strncpy(mcc, str, sizeof(mcc));
> +       mcc[3] = '\0';
> 
> maybe I am blind, but how is this suppose to work. The sizeof(mmc) is 1
> byte.

Actually, it is the size of a pointer, which will work (by accident) on
32-bits platform, and overflow on others. 

-- 
Rémi Denis-Courmont

_______________________________________________
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono

Reply via email to