about summary refs log tree commit diff
path: root/inet/inet6_rth.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-03-15 20:35:02 +0000
committerUlrich Drepper <drepper@redhat.com>2009-03-15 20:35:02 +0000
commitcd2d01faa53a48640e97d55aa0bf2fee99a7c8cb (patch)
treebe6747470cd66cf8ae86c10503370ff6dca39945 /inet/inet6_rth.c
parent906dd40db380c58794d252a112bd079b5d5f4dc6 (diff)
downloadglibc-cd2d01faa53a48640e97d55aa0bf2fee99a7c8cb.tar.gz
glibc-cd2d01faa53a48640e97d55aa0bf2fee99a7c8cb.tar.xz
glibc-cd2d01faa53a48640e97d55aa0bf2fee99a7c8cb.zip
[BZ #9880]
	* inet/inet6_rth.c (inet6_rth_reverse): Compute number of segments
	correctly.  Set segleft member in output as required.
	Patch partly by Yang Hongyang <yanghy@cn.fujitsu.com>.
	* inet/tst-inet6_rth.c (do_test): Add tests for inet6_rth_reverse.
Diffstat (limited to 'inet/inet6_rth.c')
-rw-r--r--inet/inet6_rth.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/inet/inet6_rth.c b/inet/inet6_rth.c
index e0fad339a9..36269fc6a4 100644
--- a/inet/inet6_rth.c
+++ b/inet/inet6_rth.c
@@ -130,7 +130,7 @@ inet6_rth_reverse (const void *in, void *out)
       /* Copy header, not the addresses.  The memory regions can overlap.  */
       memmove (out_rthdr0, in_rthdr0, sizeof (struct ip6_rthdr0));
 
-      int total = in_rthdr0->ip6r0_segleft * 8 / sizeof (struct in6_addr);
+      int total = in_rthdr0->ip6r0_len * 8 / sizeof (struct in6_addr);
       for (int i = 0; i < total / 2; ++i)
 	{
 	  /* Remember, IN_RTHDR0 and OUT_RTHDR0 might overlap.  */
@@ -141,6 +141,8 @@ inet6_rth_reverse (const void *in, void *out)
       if (total % 2 != 0 && in != out)
 	out_rthdr0->ip6r0_addr[total / 2] = in_rthdr0->ip6r0_addr[total / 2];
 
+      out_rthdr0->ip6r0_segleft = total;
+
       return 0;
     }