Skip to content

Commit f6fafb7

Browse files
authored
Fix incorrect command size sent over USB
1 parent 1cffc06 commit f6fafb7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/G25manage/G25manage.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ int usb_rebind_kernel_driver_np()
120120
}
121121

122122

123-
int G25send_command(char command[7]) {
123+
int G25send_command(const char *command, unsigned int command_size) {
124124

125125
int stat;
126126

@@ -143,7 +143,7 @@ int G25send_command(char command[7]) {
143143
}
144144
if (verbose_flag) printf ("USB interface claimed\n");
145145

146-
stat=usb_interrupt_write(usb_handle, 1, command, sizeof(command), 100);
146+
stat=usb_interrupt_write(usb_handle, 1, command, command_size, 100);
147147
if ( (stat < 0) ) {
148148
if ( (stat == -ENODEV) && verbose_flag) fprintf(stderr, "usb_interrupt_write: No such device, changed identity ?\n");
149149
}
@@ -174,7 +174,7 @@ int G25native() {
174174
dev=usb_find_device(VENDOR,G25NORMAL);
175175
if ( dev != NULL ) {
176176
char setextended[] = { 0xf8, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00 };
177-
G25send_command(setextended);
177+
G25send_command(setextended, sizeof(setextended));
178178
}
179179
else {
180180
printf ("Unable to find G25 device.\n");
@@ -186,7 +186,7 @@ int G25range(unsigned short int range) {
186186
dev=usb_find_device(VENDOR,G25EXTENDED);
187187
if ( dev != NULL ) {
188188
char setrange[] = { 0xf8, 0x81, range & 0x00ff , (range & 0xff00)>>8, 0x00, 0x00, 0x00 };
189-
G25send_command(setrange);
189+
G25send_command(setrange, sizeof(setrange));
190190
}
191191
return 0;
192192
}

0 commit comments

Comments
 (0)