Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Jun 2020 22:52:57 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 247129] [PATCH] Fix some compiler warnings in netinet alias module
Message-ID:  <bug-247129-227-4z2XFeIwaw@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-247129-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-247129-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D247129

--- Comment #2 from nikethmurali@protonmail.com ---
Comment on attachment 215410
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D215410
Patch for /sys/netinet/libalias/alias.c

Index: alias.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- alias.c     (revision 361967)
+++ alias.c     (working copy)
@@ -443,7 +443,8 @@
 IcmpAliasIn(struct libalias *la, struct ip *pip)
 {
        struct icmp *ic;
-       int dlen, iresult;
+       uint16_t dlen;
+       int iresult;

        LIBALIAS_LOCK_ASSERT(la);

@@ -740,7 +741,7 @@
 {
        struct udphdr *ud;
        struct alias_link *lnk;
-       int dlen;
+       uint16_t dlen;

        LIBALIAS_LOCK_ASSERT(la);

@@ -839,7 +840,8 @@
        u_short dest_port;
        u_short proxy_server_port;
        int proxy_type;
-       int dlen, error;
+       uint16_t dlen;
+       int error;

        LIBALIAS_LOCK_ASSERT(la);

@@ -944,7 +946,7 @@
 {
        struct tcphdr *tc;
        struct alias_link *lnk;
-       int dlen;
+       uint16_t dlen;

        LIBALIAS_LOCK_ASSERT(la);

@@ -1069,7 +1071,8 @@
 static int
 TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int
create)
 {
-       int dlen, proxy_type, error;
+       uint16_t dlen;
+       int proxy_type, error;
        u_short dest_port;
        u_short proxy_server_port;
        struct in_addr dest_address;
@@ -1343,9 +1346,10 @@
 static int
 LibAliasInLocked(struct libalias *la, char *ptr, int maxpacketsize)
 {
-       struct in_addr alias_addr;
+       struct in_addr alias_addr,ip_dst;
        struct ip *pip;
        int iresult;
+       u_short ip_sum ;

        if (la->packetAliasMode & PKT_ALIAS_REVERSE) {
                la->packetAliasMode &=3D ~PKT_ALIAS_REVERSE;
@@ -1398,14 +1402,24 @@
                        error =3D find_handler(IN, IP, la, pip, &ad);
                        if (error =3D=3D  0)
                                iresult =3D PKT_ALIAS_OK;
-                       else
+                       else {
+                               ip_dst =3D pip->ip_dst;
+                               ip_sum =3D pip->ip_sum;
                                iresult =3D ProtoAliasIn(la, pip->ip_src,=20
-                                   &pip->ip_dst, pip->ip_p, &pip->ip_sum);
+                                   &ip_dst, pip->ip_p, &ip_sum);
+                               pip->ip_dst =3D ip_dst;
+                               pip->ip_sum =3D ip_sum;
+                       }
                }
                        break;=20
-               default:
-                       iresult =3D ProtoAliasIn(la, pip->ip_src, &pip->ip_=
dst,
-                           pip->ip_p, &pip->ip_sum);
+               default: {
+                       ip_dst =3D pip->ip_dst;
+                       ip_sum =3D pip->ip_sum;
+                       iresult =3D ProtoAliasIn(la, pip->ip_src, &ip_dst,
+                           pip->ip_p, &ip_sum);
+                       }
+                       pip->ip_dst =3D ip_dst;
+                       pip->ip_sum =3D ip_sum;
                        break;
                }

@@ -1421,8 +1435,12 @@
                        }
                }
        } else {
-               iresult =3D FragmentIn(la, pip->ip_src, &pip->ip_dst, pip->=
ip_id,
-                   &pip->ip_sum);
+               ip_dst =3D pip->ip_dst;
+               ip_sum =3D pip->ip_sum;
+               iresult =3D FragmentIn(la, pip->ip_src, &ip_dst, pip->ip_id,
+                   &ip_sum);
+               pip->ip_dst =3D ip_dst;
+               pip->ip_sum =3D ip_sum;
        }

 getout:
@@ -1479,8 +1497,9 @@
 )
 {
        int iresult;
-       struct in_addr addr_save;
+       struct in_addr addr_save,ip_src;
        struct ip *pip;
+       u_short ip_sum;

        if (la->packetAliasMode & PKT_ALIAS_REVERSE) {
                la->packetAliasMode &=3D ~PKT_ALIAS_REVERSE;
@@ -1555,18 +1574,33 @@
                        error =3D find_handler(OUT, IP, la, pip, &ad);
                        if (error =3D=3D 0)
                                iresult =3D PKT_ALIAS_OK;
-                       else
-                               iresult =3D ProtoAliasOut(la, &pip->ip_src,=
=20
-                                   pip->ip_dst, pip->ip_p, &pip->ip_sum,
create);
+                       else {
+                               ip_src =3D pip->ip_src;
+                               ip_sum =3D pip->ip_sum;
+                               iresult =3D ProtoAliasOut(la, &ip_src,=20
+                                   pip->ip_dst, pip->ip_p, &ip_sum, create=
);
+                               pip->ip_src =3D ip_src;
+                               pip->ip_sum =3D ip_sum;
+                       }
                }
                        break;
-               default:
-                       iresult =3D ProtoAliasOut(la, &pip->ip_src,
-                           pip->ip_dst, pip->ip_p, &pip->ip_sum, create);
+               default: {
+                       ip_src =3D pip->ip_src;
+                       ip_sum =3D pip->ip_sum;
+                       iresult =3D ProtoAliasOut(la, &ip_src,
+                           pip->ip_dst, pip->ip_p, &ip_sum, create);
+                       pip->ip_src =3D ip_src;
+                       pip->ip_sum =3D ip_sum;
+               }
                        break;
                }
        } else {
-               iresult =3D FragmentOut(la, &pip->ip_src, &pip->ip_sum);
+               ip_src =3D pip->ip_src;
+               ip_sum =3D pip->ip_sum;
+               iresult =3D FragmentOut(la, &ip_src, &ip_sum);
+               pip->ip_src =3D ip_src;
+               pip->ip_sum =3D ip_sum;
+
        }

        SetDefaultAliasAddress(la, addr_save);

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-247129-227-4z2XFeIwaw>