[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ipsec-tools-devel
Subject:    Re: [Ipsec-tools-devel] [PATCH v3 4/5] Check for strtouq
From:       Jörg Krause <joerg.krause () embedded ! rocks>
Date:       2016-05-10 18:52:11
Message-ID: 1462906331.12640.2.camel () embedded ! rocks
[Download RAW message or body]

On Mo, 2016-05-09 at 18:14 +0100, Rainer Weikusat wrote:
> Jörg Krause <joerg.krause@embedded.rocks> writes:
> 
> [...]
> 
> > diff -purN ipsec-tools-0.8.2-3/configure.ac ipsec-tools-0.8.2-
> > 4/configure.ac
> > --- ipsec-tools-0.8.2-3/configure.ac	2016-05-08
> > 12:09:07.692445249 +0200
> > +++ ipsec-tools-0.8.2-4/configure.ac	2016-05-08
> > 12:11:17.661679674 +0200
> > @@ -124,7 +124,7 @@ AC_STRUCT_TM
> >  AC_FUNC_MEMCMP
> >  AC_TYPE_SIGNAL
> >  AC_FUNC_VPRINTF
> > -AC_CHECK_FUNCS(gettimeofday select socket strerror strtol strtoul
> > strlcpy strlcat)
> > +AC_CHECK_FUNCS(gettimeofday select socket strerror strtol strtoul
> > strtoull strtouq strlcpy strlcat)
> >  AC_REPLACE_FUNCS(strdup)
> >  RACOON_CHECK_VA_COPY
> >  
> > diff -purN ipsec-tools-0.8.2-3/src/racoon/misc.h ipsec-tools-0.8.2-
> > 4/src/racoon/misc.h
> > --- ipsec-tools-0.8.2-3/src/racoon/misc.h	2016-05-08
> > 12:09:28.132324323 +0200
> > +++ ipsec-tools-0.8.2-4/src/racoon/misc.h	2016-05-08
> > 12:11:17.661679674 +0200
> > @@ -75,6 +75,14 @@ extern void close_on_exec __P((int fd));
> >  #define strlcat(d,s,l) strncat(d,s,(l)-strlen(d)-1)
> >  #endif
> >  
> > +#ifndef HAVE_STRTOUQ
> > +#  ifdef HAVE_STRTOULL
> > +#    define strtouq strtoull
> > +#  elif HAVE_STRTOUL
> > +#    define strtouq strtoul
> > +#  endif
> > +#endif
> > +
> >  #define STRDUP_FATAL(x) if (x == NULL) {			\
> >  	plog(LLV_ERROR, LOCATION, NULL, "strdup failed\n");	
> > \
> >  	exit(1);						\
> 
> I had a closer look at the code:
> 
> strtouq is only used in backupsa.c and it's actually useless there
> because the return value is assigned to an u_int32_t. That's this
> code:
> 
>                 GETNEXTNUM(sa_args.l_bytes, strtouq);
>                 GETNEXTNUM(sa_args.l_addtime, strtouq);
>                 GETNEXTNUM(sa_args.l_usetime, strtouq);
> 
> and the structure definition is (libipsec/libpfkey.h)
> 
> struct pfkey_send_sa_args {
> 
> [...]
> 
>         u_int32_t       l_bytes;
>         u_int32_t       l_addtime;
>         u_int32_t       l_usetime;
> 
> 'lifebytes' is deprecated. The other two are both SA lifetimes in
> seconds either from date of creation (addtime) or date of first use
> (usetime). Considering that the values are unsigned, the maximum
> lifetime would be more than 130 years which ought to be sufficient
> for a
> ph2 SA. Consequently, I suggest to avoid this complication and just
> use
> strtoul.

Many thanks for looking at this!

> ---
> --- ipsec-tools-0.8.2/src/racoon/backupsa.c	2010-04-02
> 16:15:00.000000000 +0100
> +++ ipsec-tools-0.8.2.p/src/racoon/backupsa.c	2016-05-09
> 18:00:49.448253909 +0100
> @@ -276,9 +276,9 @@ do { 						
> 		\
>  		GETNEXTNUM(sa_args.a_keylen, strtoul);
>  		GETNEXTNUM(sa_args.flags, strtoul);
>  		GETNEXTNUM(sa_args.l_alloc, strtoul);
> -		GETNEXTNUM(sa_args.l_bytes, strtouq);
> -		GETNEXTNUM(sa_args.l_addtime, strtouq);
> -		GETNEXTNUM(sa_args.l_usetime, strtouq);
> +		GETNEXTNUM(sa_args.l_bytes, strtoul);
> +		GETNEXTNUM(sa_args.l_addtime, strtoul);
> +		GETNEXTNUM(sa_args.l_usetime, strtoul);
>  		GETNEXTNUM(sa_args.seq, strtoul);
>  
>  #undef GETNEXTNUM

Looks good to me! I'll update the patch soon...

Best regards
Jörg Krause

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Ipsec-tools-devel mailing list
Ipsec-tools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipsec-tools-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic