Bug#406251: pcmciautils: lspcmcia -v segfaults on unknown function

Colin Watson cjwatson at debian.org
Wed Jan 10 02:24:38 EST 2007


On Tue, Jan 09, 2007 at 09:32:09PM +0100, Samuel Thibault wrote:
> Package: pcmciautils
> Version: 014-3
> Severity: normal
> Tags: patch
> 
> Hi,
> 
> # lspcmcia -v
> Socket 0 Bridge:        [yenta_cardbus]         (bus ID: 0000:02:03.0)
>         Configuration:  state: on       ready: yes
>                         Voltage: 3.3V Vcc: 3.3V Vpp: 3.3V
> Socket 0 Device 0:      [-- no driver --]       (bus ID: 0.0)
>         Configuration:  state: on
>         Product Name:   RICOH Bay1Controller 
>         Identification: manf_id: 0x0000 card_id: 0x0000
> Segmentation fault.
> 
> This is because the device reports function 254, which is out of the fn
> array, see attached fix.

This patch looks reasonable to me. Dominik?

> diff -ur pcmciautils-014/src/pccardctl.c pcmciautils-014-mine/src/pccardctl.c
> --- pcmciautils-014/src/pccardctl.c	2006-06-01 11:07:52.000000000 +0200
> +++ pcmciautils-014-mine/src/pccardctl.c	2007-01-09 21:29:25.000000000 +0100
> @@ -250,7 +250,7 @@
>  			printf("  manfid: 0x%04x, 0x%04x\n", manf_id, card_id);
>  
>  	if (!pccardctl_get_one(socket_no, "func_id", &manf_id))
> -		printf("  function: %d (%s)\n", manf_id, fn[manf_id]);
> +		printf("  function: %d (%s)\n", manf_id, manf_id < sizeof(fn)/sizeof(*fn) ? fn[manf_id] : "unknown");
>  
>  
>  	return 0;
> @@ -586,7 +586,7 @@
>  				if (!pccardctl_get_one(socket_no, "card_id", &card_id))
>  					printf("manf_id: 0x%04x\tcard_id: 0x%04x\n\t\t\t", manf_id, card_id);
>  			if (!pccardctl_get_one(socket_no, "func_id", &manf_id))
> -				printf("function: %d (%s)\n\t\t\t", manf_id, fn[manf_id]);
> +				printf("function: %d (%s)\n\t\t\t", manf_id, manf_id < sizeof(fn)/sizeof(*fn) ? fn[manf_id] : "unknown");
>  			for (j=1;j<=4;j++) {
>  				snprintf(file, SYSFS_PATH_MAX, "prod_id%d", j);
>  				pccardctl_get_string(socket_no, file, &res);

Thanks,

-- 
Colin Watson                                       [cjwatson at debian.org]



More information about the linux-pcmcia mailing list