diff options
Diffstat (limited to 'usr.bin/netstat/mroute.c')
-rw-r--r-- | usr.bin/netstat/mroute.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c index 975473e..d4d6014 100644 --- a/usr.bin/netstat/mroute.c +++ b/usr.bin/netstat/mroute.c @@ -100,17 +100,19 @@ print_bw_meter(struct bw_meter *bw_meter, int *banner_printed) /* The measured values */ if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS) { - sprintf(s1, "%ju", (uintmax_t)bw_meter->bm_measured.b_packets); + snprintf(s1, sizeof(s1), "%ju", + (uintmax_t)bw_meter->bm_measured.b_packets); xo_emit("{e:measured-packets/%ju}", (uintmax_t)bw_meter->bm_measured.b_packets); } else - sprintf(s1, "?"); + strcpy(s1, "?"); if (bw_meter->bm_flags & BW_METER_UNIT_BYTES) { - sprintf(s2, "%ju", (uintmax_t)bw_meter->bm_measured.b_bytes); + snprintf(s2, sizeof(s2), "%ju", + (uintmax_t)bw_meter->bm_measured.b_bytes); xo_emit("{e:measured-bytes/%ju}", (uintmax_t)bw_meter->bm_measured.b_bytes); } else - sprintf(s2, "?"); + strcpy(s2, "?"); xo_emit(" {[:-30}{:start-time/%lu.%06lu}|{q:measured-packets/%s}" "|{q:measured-bytes%s}{]:}", (u_long)bw_meter->bm_start_time.tv_sec, @@ -122,17 +124,19 @@ print_bw_meter(struct bw_meter *bw_meter, int *banner_printed) /* The threshold values */ if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS) { - sprintf(s1, "%ju", (uintmax_t)bw_meter->bm_threshold.b_packets); + snprintf(s1, sizeof(s1), "%ju", + (uintmax_t)bw_meter->bm_threshold.b_packets); xo_emit("{e:threshold-packets/%ju}", (uintmax_t)bw_meter->bm_threshold.b_packets); } else - sprintf(s1, "?"); + strcpy(s1, "?"); if (bw_meter->bm_flags & BW_METER_UNIT_BYTES) { - sprintf(s2, "%ju", (uintmax_t)bw_meter->bm_threshold.b_bytes); + snprintf(s2, sizeof(s2), "%ju", + (uintmax_t)bw_meter->bm_threshold.b_bytes); xo_emit("{e:threshold-bytes/%ju}", (uintmax_t)bw_meter->bm_threshold.b_bytes); } else - sprintf(s2, "?"); + strcpy(s2, "?"); xo_emit(" {[:-30}{:threshold-time/%lu.%06lu}|{q:threshold-packets/%s}" "|{q:threshold-bytes%s}{]:}", @@ -144,13 +148,13 @@ print_bw_meter(struct bw_meter *bw_meter, int *banner_printed) &bw_meter->bm_threshold.b_time, &end); if (timercmp(&now, &end, <=)) { timersub(&end, &now, &delta); - sprintf(s3, "%lu.%06lu", + snprintf(s3, sizeof(s3), "%lu.%06lu", (u_long)delta.tv_sec, (u_long)delta.tv_usec); } else { /* Negative time */ timersub(&now, &end, &delta); - sprintf(s3, "-%lu.06%lu", + snprintf(s3, sizeof(s3), "-%lu.06%lu", (u_long)delta.tv_sec, (u_long)delta.tv_usec); } |