[lxc-devel] [PATCH] don't compare unsigned values as negative ones

Stéphane Graber stgraber at ubuntu.com
Mon Apr 13 23:03:37 UTC 2015


On Mon, Apr 13, 2015 at 04:43:30PM -0600, Tycho Andersen wrote:
> Instead, check that the result is larger than its parts.
> 
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  src/lxc/utils.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lxc/utils.c b/src/lxc/utils.c
> index 084b556..fe71e9a 100644
> --- a/src/lxc/utils.c
> +++ b/src/lxc/utils.c
> @@ -1645,12 +1645,13 @@ int setproctitle(char *title)
>  			env_start = env_end;
>  		}
>  
> +		arg_end = arg_start + len;
> +
>  		/* check overflow */
> -		if (arg_start + len < 0) {
> +		if (arg_end < len || arg_end < arg_start) {
>  			return -1;
>  		}
>  
> -		arg_end = arg_start + len;
>  	}
>  
>  	strcpy((char*)arg_start, title);
> -- 
> 2.1.0
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20150413/74edf093/attachment.sig>


More information about the lxc-devel mailing list