ip6_sysctl_soiikey: use IP6_SOIIKEY_LEN instead of hardcoded value

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

ip6_sysctl_soiikey: use IP6_SOIIKEY_LEN instead of hardcoded value

Sebastien Marie-3
Hi,

I think it is preferable to not hardcode IP6_SOIIKEY_LEN in
ip6_sysctl_soiikey().

No changes expected, as IP6_SOIIKEY_LEN is 16.

netinet6/ip6_var.h
   295  #define IP6_SOIIKEY_LEN 16
   296  extern uint8_t  ip6_soiikey[IP6_SOIIKEY_LEN];

Thanks.
--
Sebastien Marie


Index: netinet6/ip6_input.c
===================================================================
RCS file: /cvs/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.212
diff -u -p -U10 -r1.212 ip6_input.c
--- netinet6/ip6_input.c 10 Feb 2018 05:52:08 -0000 1.212
+++ netinet6/ip6_input.c 12 Feb 2018 09:07:05 -0000
@@ -1367,21 +1367,21 @@ ip6_sysctl_ip6stat(void *oldp, size_t *o
     ip6stat, sizeof(*ip6stat));
  free(ip6stat, M_TEMP, sizeof(*ip6stat));
 
  return (ret);
 }
 
 int
 ip6_sysctl_soiikey(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
 {
  struct ifnet *ifp;
- uint8_t oldkey[16];
+ uint8_t oldkey[IP6_SOIIKEY_LEN];
  int error;
 
  error = suser(curproc, 0);
  if (error != 0)
  return (error);
 
  memcpy(oldkey, ip6_soiikey, sizeof(oldkey));
 
  error = sysctl_struct(oldp, oldlenp, newp, newlen, ip6_soiikey,
     sizeof(ip6_soiikey));

Reply | Threaded
Open this post in threaded view
|

Re: ip6_sysctl_soiikey: use IP6_SOIIKEY_LEN instead of hardcoded value

Sebastian Benoit-3

ok

Sebastien Marie([hidden email]) on 2018.02.12 10:07:48 +0100:

> Hi,
>
> I think it is preferable to not hardcode IP6_SOIIKEY_LEN in
> ip6_sysctl_soiikey().
>
> No changes expected, as IP6_SOIIKEY_LEN is 16.
>
> netinet6/ip6_var.h
>    295  #define IP6_SOIIKEY_LEN 16
>    296  extern uint8_t  ip6_soiikey[IP6_SOIIKEY_LEN];
>
> Thanks.
> --
> Sebastien Marie
>
>
> Index: netinet6/ip6_input.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/ip6_input.c,v
> retrieving revision 1.212
> diff -u -p -U10 -r1.212 ip6_input.c
> --- netinet6/ip6_input.c 10 Feb 2018 05:52:08 -0000 1.212
> +++ netinet6/ip6_input.c 12 Feb 2018 09:07:05 -0000
> @@ -1367,21 +1367,21 @@ ip6_sysctl_ip6stat(void *oldp, size_t *o
>      ip6stat, sizeof(*ip6stat));
>   free(ip6stat, M_TEMP, sizeof(*ip6stat));
>  
>   return (ret);
>  }
>  
>  int
>  ip6_sysctl_soiikey(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
>  {
>   struct ifnet *ifp;
> - uint8_t oldkey[16];
> + uint8_t oldkey[IP6_SOIIKEY_LEN];
>   int error;
>  
>   error = suser(curproc, 0);
>   if (error != 0)
>   return (error);
>  
>   memcpy(oldkey, ip6_soiikey, sizeof(oldkey));
>  
>   error = sysctl_struct(oldp, oldlenp, newp, newlen, ip6_soiikey,
>      sizeof(ip6_soiikey));
>