decrementing Uninitialized ttl value

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

decrementing Uninitialized ttl value

Bijan Ebrahimi
Hi, while reading the changes in OpenBSD source code (hopefully to learn
more), I've notice the usage of Uninitialized variable. Looks like the
latest commit unintentionally removed the assignment line:

https://github.com/openbsd/src/commit/5c53b9324545b7febab2dcf52402199d72b231d3?diff=split#diff-3efc580dfa272b2173162f5950c92484R86

The following should bring back (the possibly) unwanted change. Hope it
helps unless I missed something :-)

diff --git a/sys/netmpls/mpls_input.c b/sys/netmpls/mpls_input.c
index 34fe7314d..487506301 100644
--- a/sys/netmpls/mpls_input.c
+++ b/sys/netmpls/mpls_input.c
@@ -83,6 +83,7 @@ mpls_input(struct ifnet *ifp, struct mbuf *m)
  #endif

         /* check and decrement TTL */
+       ttl = ntohl(shim->shim_label & MPLS_TTL_MASK);
         if (--ttl == 0) {
                 /* TTL exceeded */
                 m = mpls_do_error(m, ICMP_TIMXCEED,
ICMP_TIMXCEED_INTRANS, 0);

Reply | Threaded
Open this post in threaded view
|

Re: decrementing Uninitialized ttl value

Bijan Ebrahimi
definitely a more clean diff

diff --git a/sys/netmpls/mpls_input.c b/sys/netmpls/mpls_input.c
index 34fe7314d..fff3564c8 100644
--- a/sys/netmpls/mpls_input.c
+++ b/sys/netmpls/mpls_input.c
@@ -76,13 +76,15 @@ mpls_input(struct ifnet *ifp, struct mbuf *m)
         }

         shim = mtod(m, struct shim_hdr *);
-
  #ifdef MPLS_DEBUG
         printf("mpls_input: iface %s label=%d, ttl=%d BoS %d\n",
-           ifp->if_xname, MPLS_LABEL_GET(shim->shim_label), ttls, hasbos);
+           ifp->if_xname, MPLS_LABEL_GET(shim->shim_label),
+           MPLS_LABEL_GET(shim->shim_label),
+           MPLS_BOS_ISSET(shim->shim_label));
  #endif

         /* check and decrement TTL */
+       ttl = MPLS_LABEL_GET(shim->shim_label);
         if (--ttl == 0) {
                 /* TTL exceeded */
                 m = mpls_do_error(m, ICMP_TIMXCEED,
ICMP_TIMXCEED_INTRANS, 0);


On 01/09/18 22:31, bijan wrote:

> Hi, while reading the changes in OpenBSD source code (hopefully to
> learn more), I've notice the usage of Uninitialized variable. Looks
> like the latest commit unintentionally removed the assignment line:
>
> https://github.com/openbsd/src/commit/5c53b9324545b7febab2dcf52402199d72b231d3?diff=split#diff-3efc580dfa272b2173162f5950c92484R86 
>
>
> The following should bring back (the possibly) unwanted change. Hope
> it helps unless I missed something :-)
>
> diff --git a/sys/netmpls/mpls_input.c b/sys/netmpls/mpls_input.c
> index 34fe7314d..487506301 100644
> --- a/sys/netmpls/mpls_input.c
> +++ b/sys/netmpls/mpls_input.c
> @@ -83,6 +83,7 @@ mpls_input(struct ifnet *ifp, struct mbuf *m)
>  #endif
>
>         /* check and decrement TTL */
> +       ttl = ntohl(shim->shim_label & MPLS_TTL_MASK);
>         if (--ttl == 0) {
>                 /* TTL exceeded */
>                 m = mpls_do_error(m, ICMP_TIMXCEED,
> ICMP_TIMXCEED_INTRANS, 0);
>