Project

General

Profile

Actions

Bug #9834

open

Missing format option and possible wrong condition in source file usr/src/cmd/cmd-inet/lib/nwamd/routing_events.c

Added by Haoran Wang about 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
cmd - userland programs
Start date:
2018-09-12
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
needs-triage
Gerrit CR:
External Bug:

Description

In this source file, function routing_events_v4:

135        if (rtm->rtm_msglen < n) {
136            nlog(LOG_ERR, "only read %d bytes from " 
137                "routing socket but message claims to be " 
138                "of length %d", rtm->rtm_msglen);
139            continue;
140        }

2 '%d' but only 1 argument is given; function routing_events_v6 have same issue.
I initially thinking the code should be:
         if (rtm->rtm_msglen < n) {
             nlog(LOG_ERR, "only read %d bytes from " 
                 "routing socket but message claims to be " 
-                "of length %d", rtm->rtm_msglen);
+                "of length %d", n, rtm->rtm_msglen);
             continue;
         }

However I found the condition statement was conflicts with the error message; according to error message, 'rtm->rtm_msglen' was unexpectedly greater than 'n', not little than.
So the patch would be:
--- 1/usr/src/cmd/cmd-inet/lib/nwamd/routing_events.c    2012-11-06 15:51:53.000000000 +0800
+++ 2/usr/src/cmd/cmd-inet/lib/nwamd/routing_events.c    2018-09-12 22:35:47.141767709 +0800
@@ -132,10 +132,10 @@
             continue;
         }

-        if (rtm->rtm_msglen < n) {
+        if (rtm->rtm_msglen > n) {
             nlog(LOG_ERR, "only read %d bytes from " 
                 "routing socket but message claims to be " 
-                "of length %d", rtm->rtm_msglen);
+                "of length %d", n, rtm->rtm_msglen);
             continue;
         }
 

Or is it better to test the equality by simply use 'if (rtm->rtm_msglen != n)' ?
Can someone confirm the correct fix?

No data to display

Actions

Also available in: Atom PDF