Skip to content

Commit

Permalink
Fixing shitcode with more shitcode
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasili-Sk committed Oct 25, 2021
1 parent 47dbff6 commit bd26d58
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions socketcandcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,13 @@ inline void state_connected() {

sscanf(buf, "< frame %x %*d.%*d %s >", &frame.can_id, data_str);

if (element_length(buf, 2) == 8)
char *s = buf + 7;
for (; ++s;) {
if (*s == ' ') {
break;
}
}
if ((s - buf - 7) > 4)
frame.can_id |= CAN_EFF_FLAG;

frame.can_dlc = strlen(data_str) / 2;
Expand All @@ -322,8 +328,15 @@ inline void state_connected() {
//force DLC 0 since it is undocumented feature
frame.can_dlc = 0;
frame.can_id |= CAN_RTR_FLAG;
if (element_length(buf, 2) == 8)
frame.can_id |= CAN_EFF_FLAG; //extended

char *s = buf + 6;
for (; ++s;) {
if (*s == ' ') {
break;
}
}
if ((s - buf - 7) > 4)
frame.can_id |= CAN_EFF_FLAG;

ret = write(raw_socket, &frame, sizeof(struct can_frame));
if (ret < sizeof(struct can_frame)) {
Expand Down

0 comments on commit bd26d58

Please sign in to comment.