bcmserver: allow CAN netdevice names greater than 6 characters
The sscanf() function to parse bcmserver command strings limited the length of the CAN netdevice name to six characters. With this patch the length is derived from the IFNAMSIZ which defines the space in ifr.ifr_name. Signed-off-by: Jiho Chu <jiho.chu@samsung.com> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>pull/4/merge
parent
c3305fdd51
commit
99f1664e0c
11
bcmserver.c
11
bcmserver.c
|
|
@ -126,6 +126,7 @@
|
||||||
#include <linux/can/bcm.h>
|
#include <linux/can/bcm.h>
|
||||||
|
|
||||||
#define MAXLEN 100
|
#define MAXLEN 100
|
||||||
|
#define FORMATSZ 80
|
||||||
#define PORT 28600
|
#define PORT 28600
|
||||||
|
|
||||||
void childdied(int i)
|
void childdied(int i)
|
||||||
|
|
@ -149,6 +150,7 @@ int main(int argc, char **argv)
|
||||||
sigset_t sigset;
|
sigset_t sigset;
|
||||||
|
|
||||||
char buf[MAXLEN];
|
char buf[MAXLEN];
|
||||||
|
char format[FORMATSZ];
|
||||||
char rxmsg[50];
|
char rxmsg[50];
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -156,6 +158,11 @@ int main(int argc, char **argv)
|
||||||
struct can_frame frame;
|
struct can_frame frame;
|
||||||
} msg;
|
} msg;
|
||||||
|
|
||||||
|
if (snprintf(format, FORMATSZ, "< %%%ds %%c %%lu %%lu %%x %%hhu "
|
||||||
|
"%%hhx %%hhx %%hhx %%hhx %%hhx %%hhx "
|
||||||
|
"%%hhx %%hhx >", IFNAMSIZ-1) >= FORMATSZ-1)
|
||||||
|
exit(1);
|
||||||
|
|
||||||
sigemptyset(&sigset);
|
sigemptyset(&sigset);
|
||||||
signalaction.sa_handler = &childdied;
|
signalaction.sa_handler = &childdied;
|
||||||
signalaction.sa_mask = sigset;
|
signalaction.sa_mask = sigset;
|
||||||
|
|
@ -282,9 +289,7 @@ int main(int argc, char **argv)
|
||||||
memset(&msg, 0, sizeof(msg));
|
memset(&msg, 0, sizeof(msg));
|
||||||
msg.msg_head.nframes = 1;
|
msg.msg_head.nframes = 1;
|
||||||
|
|
||||||
items = sscanf(buf, "< %6s %c %lu %lu %x %hhu "
|
items = sscanf(buf, format,
|
||||||
"%hhx %hhx %hhx %hhx %hhx %hhx "
|
|
||||||
"%hhx %hhx >",
|
|
||||||
ifr.ifr_name,
|
ifr.ifr_name,
|
||||||
&cmd,
|
&cmd,
|
||||||
&msg.msg_head.ival2.tv_sec,
|
&msg.msg_head.ival2.tv_sec,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue