pcmciautils/pcmciautils-014-funcname.patch
Harald Hoyer 5d31c74cb6 - fixed 'pccardctl ident' SEGV
- Resolves: rhbz#242805
2007-06-06 10:48:33 +00:00

38 lines
1.2 KiB
Diff

--- pcmciautils-014/src/pccardctl.c~ 2006-06-01 10:07:52.000000000 +0100
+++ pcmciautils-014/src/pccardctl.c 2007-06-05 22:20:36.000000000 +0100
@@ -37,6 +37,7 @@ static char *fn[] = {
"AIMS",
"SCSI"
};
+#define NR_FNS ( sizeof(fn) / sizeof(*fn) )
/* crc32hash.c - derived from linux/lib/crc32.c, GNU GPL v2 */
static unsigned int crc32(unsigned char const *p, unsigned int len)
@@ -219,7 +220,7 @@ static int pccardctl_ident(unsigned long
char *prod_id[4];
int valid_prod_id = 0;
int i;
- unsigned int manf_id, card_id;
+ unsigned int manf_id, card_id, func_id;
if (!pccardctl_socket_exists(socket_no))
return -ENODEV;
@@ -249,9 +250,15 @@ static int pccardctl_ident(unsigned long
if (!pccardctl_get_one(socket_no, "card_id", &card_id))
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]);
+ if (!pccardctl_get_one(socket_no, "func_id", &func_id)) {
+ char *func_name;
+ if (func_id < NR_FNS)
+ func_name = fn[func_id];
+ else
+ func_name = "unknown";
+ printf(" function: 0x%x (%s), %d\n", func_id, func_name, NR_FNS);
+ }
return 0;
}