diff --git a/tools/atrf-proxy/atrf-proxy.c b/tools/atrf-proxy/atrf-proxy.c index be06382..0d36369 100644 --- a/tools/atrf-proxy/atrf-proxy.c +++ b/tools/atrf-proxy/atrf-proxy.c @@ -73,7 +73,7 @@ static int cmd_two(struct atrf_dsc *dsc, struct netio *netio, const char *cmd) return ret; if (val > 255) return netio_printf(netio, "-bad argument\n"); - atrf_reg_write(dsc, n, ret); + atrf_reg_write(dsc, n, val); if (atrf_error(dsc)) return netio_printf(netio, "-I/O error\n"); return netio_printf(netio, "+\n"); diff --git a/tools/lib/atnet.c b/tools/lib/atnet.c index b857598..8b91006 100644 --- a/tools/lib/atnet.c +++ b/tools/lib/atnet.c @@ -321,15 +321,22 @@ static int atnet_buf_read(void *dsc, void *buf, int size) goto fail; n = netio_read_until(netio, " ", tmp, sizeof(tmp)-1, NULL); + if (n < 0) + goto fail; + tmp[n] = 0; if (*tmp == '-') { - tmp[n] = 0; - fprintf(stderr, "%s\n", tmp+1); + fprintf(stderr, "%s ", tmp+1); + n = netio_read_until(netio, "\n", tmp, sizeof(tmp)-1, NULL); + if (n >= 0) { + tmp[n] = 0; + fprintf(stderr, "%s\n", tmp); + } goto fail; } - if (*tmp != '+' || n < 3) /* +0 */ + if (*tmp != '+' || n < 2) /* +0 */ goto invalid; len = strtoul(tmp+1, &end, 0); - if (*end != ' ') + if (*end) goto invalid; if (len > size) { fprintf(stderr, "buffer overflow\n");