[PATCH] Bug fixes for libgsmd-tool -m shell

Holger Freyther zecke at openmoko.org
Mon Jul 21 19:01:17 CEST 2008


On Sunday 20 July 2008 02:04:08 Jorgen Cederlof wrote:

> Index: target/gsm/src/util/shell.c
> ===================================================================
> --- target/gsm/src/util/shell.c	(revision 4541)
> +++ target/gsm/src/util/shell.c	(working copy)
> @@ -614,6 +614,7 @@
>  	char buf[STDIN_BUF_SIZE+1];
>  	fd_set readset;
>  	char *ptr, *fcomma, *lcomma;
> +	int value;
>  	int gsm_fd = lgsm_fd(lgsmh);
>  	const struct msghandler_s *hndl;
>
> @@ -696,13 +697,14 @@
>  			} else if (!strcmp(buf, "r")) {
>  				printf("Register\n");
>  				lgsm_netreg_register(lgsmh, "\0     ");
> -			} else if (!strcmp(buf,"R")) {
> +			} else if (!strncmp(buf, "R=", 2) &&
> +				   (ptr = strchr(buf, '=')) &&
> +				   strlen(ptr+1) >= 5) {
>  				printf("Register to operator\n");
> -				ptr = strchr(buf, '=');
> -				if (!ptr || strlen(ptr) < 6)

So for a string like "R=\0" you assume that strlen("\0") is 0? Took me a 
minute to figure that out. :)




More information about the devel mailing list