Hi!

Our coverity scan detected new CLANG warning after I have cherry-picked commit 03345ecefeb0d82e3c3a4c28f27c3554f0611b39 [1] into our rhel8 release. It reported it for 2.79 version, but even the last commit in master branch still has the same issue present. In attached patch I have suggested fix.

I am not sure how to trigger this code from the client, so this is not tested with real dhcp client. I track it under Fedora bug [2]. Coverity reported it as:

1. Defect type: CLANG_WARNING
1. dnsmasq-2.79/src/rfc3315.c:344:7: warning[deadcode.DeadStores]: Value stored 
to 'outmsgtype' is never read
#   342|
#   343|       {
#   344|->       outmsgtype = DHCP6REPLY;
#   345|         o1 = new_opt6(OPTION6_STATUS_CODE);
#   346|         put_opt6_short(DHCP6USEMULTI);

1. http://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=03345ecefeb0d82e3c3a4c28f27c3554f0611b39
2. https://bugzilla.redhat.com/show_bug.cgi?id=2178069

--
Petr Menšík
Software Engineer, RHEL
Red Hat,http://www.redhat.com/
PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB
From 198f1971d80692582eb3206632873295ea725556 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemen...@redhat.com>
Date: Tue, 14 Mar 2023 12:39:56 +0100
Subject: [PATCH] Fix: Value stored to 'outmsgtype' is never read

Coverity detected bug since commit 03345ecefeb0d82e3c3a4c28f27c3554f0611b39,
there is assignment not used anymore. Assign the value to the actual
packet. Still present even in 2.89 version.

1. Defect type: CLANG_WARNING
1. dnsmasq-2.79/src/rfc3315.c:344:7: warning[deadcode.DeadStores]: Value stored to 'outmsgtype' is never read
   342|
   343|       {
   344|->       outmsgtype = DHCP6REPLY;
   345|         o1 = new_opt6(OPTION6_STATUS_CODE);
   346|         put_opt6_short(DHCP6USEMULTI);
---
 src/rfc3315.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rfc3315.c b/src/rfc3315.c
index 8754481..1338c87 100644
--- a/src/rfc3315.c
+++ b/src/rfc3315.c
@@ -348,7 +348,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, unsigned char *inbu
       (msg_type == DHCP6REQUEST || msg_type == DHCP6RENEW || msg_type == DHCP6RELEASE || msg_type == DHCP6DECLINE))
     
     {  
-      outmsgtype = DHCP6REPLY;
+      ((unsigned char *)(daemon->outpacket.iov_base))[start_msg] = DHCP6REPLY;
       o1 = new_opt6(OPTION6_STATUS_CODE);
       put_opt6_short(DHCP6USEMULTI);
       put_opt6_string("Use multicast");
-- 
2.39.2

_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss

Reply via email to