Messages in this thread Patch in this message | | | Date | Sun, 20 Jul 1997 01:46:23 -0400 (EDT) | From | Jon Lewis <> | Subject | ip_fw.c fix for next pre-2.0.31 kernel |
| |
This is a fix posted by Janos Farkas <Janos.Farkas-#KvGiv60PR4d78sf8TLWFtQyus/4@iceq.ml.org> (or something) a month or two ago. It fixes a sprintf format bug that causes IP addresses to be corrupt when displayed using ipfwadm to simultaneously read and zero the counters. I'd assumed it made it into the pre-patches, but just got corruption on a pre-2.0.31-1 system, so I added it into mine, and here's an update of the diff against 31-1.
--- ip_fw.c.broken Sun Jul 20 01:30:35 1997 +++ ip_fw.c Sun Jul 20 01:33:48 1997 @@ -1191,7 +1191,7 @@ ntohl(i->fw_dst.s_addr),ntohl(i->fw_dmsk.s_addr), (i->fw_vianame)[0] ? i->fw_vianame : "-", ntohl(i->fw_via.s_addr),i->fw_flg); - len+=sprintf(buffer+len,"%u %u %-9lu %-9lu", + len+=sprintf(buffer+len,"%u %u %-10lu %-10lu", i->fw_nsp,i->fw_ndp, i->fw_pcnt,i->fw_bcnt); for (p = 0; p < IP_FW_MAX_PORTS; p++) len+=sprintf(buffer+len, " %u", i->fw_pts[p]);
I haven't tested it yet, but I plan to this week. %-9 just isn't wide enough for lu. I can't imagine this diff does anything bad. Others have tested it and declared it good.
[From a Jun 2 post by Jos Vos]
The problem with the /proc entries is known for long, I think (when will this change, please...?), and this was the reason that we _tried_ to make all entries having the same length. Unfortunately, as Alan and some others already explained, the %-9lu for printf'ing the counters is one char too small, so changing this to %-10lu will solve the problem. Some people already reported that they haven't had any problems after changing this.
------------------------------------------------------------------ Jon Lewis <jlewis@fdt.net> | Unsolicited commercial e-mail will Network Administrator | be proof-read for $199/message. Florida Digital Turnpike | ________Finger jlewis@inorganic5.fdt.net for PGP public key_______
| |