Skip to content

Commit

Permalink
Support MFC-J430W
Browse files Browse the repository at this point in the history
  • Loading branch information
rumpeltux committed Jan 22, 2019
1 parent 6764458 commit 0bdfbe4
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions data_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ exchange_params2(struct data_channel *data_channel)
}

msg_len = brother_conn_receive(data_channel->conn, data_channel->buf,
sizeof(data_channel->buf));
sizeof(data_channel->buf) - 1);
if (msg_len < 5) {
LOG_ERR("Failed to receive scan params on data_channel %s\n",
data_channel->config->ip);
Expand All @@ -495,27 +495,24 @@ exchange_params2(struct data_channel *data_channel)
data_channel->config->ip, data_channel->buf[2]);
return -1;
}

if (data_channel->buf[msg_len - 1] != 0x00) {
LOG_ERR("%s: received invalid exchange params msg (invalid last byte '%c').\n",
data_channel->config->ip, data_channel->buf[msg_len - 1]);
return -1;
}
// Make sure it's \0 terminated.
data_channel->buf[msg_len] = 0;

i = 0;
buf_end = buf = data_channel->buf + 3;

while (i < sizeof(recv_params) / sizeof(recv_params[0])) {
tmp = strtol((char *) buf, (char **) &buf_end, 10);
if (buf_end == buf || *buf_end != ',' ||
if (buf_end == buf || (*buf_end != ',' && *buf_end != 0) ||
((tmp == LONG_MIN || tmp == LONG_MAX) && errno == ERANGE)) {
LOG_ERR("%s: received invalid exchange params msg (invalid params).\n",
data_channel->config->ip);
return -1;
}

recv_params[i++] = tmp;
buf = ++buf_end;
if (*buf_end) buf_end++;
buf = buf_end;
}

if (*buf != 0x00) {
Expand Down

0 comments on commit 0bdfbe4

Please sign in to comment.