lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0bbdf1f7-9761-a135-65c4-41f72601a73b@gmail.com>
Date:   Tue, 16 May 2017 08:21:49 -0700
From:   David Ahern <dsahern@...il.com>
To:     Simon Horman <simon.horman@...ronome.com>
Cc:     netdev@...r.kernel.org, stephen@...workplumber.org
Subject: Re: [PATCH iproute2] ip: add support for more MPLS labels

On 5/16/17 1:32 AM, Simon Horman wrote:
>> diff --git a/lib/mpls_pton.c b/lib/mpls_pton.c
>> index bd448cfcf14a..6d2e6a69436a 100644
>> --- a/lib/mpls_pton.c
>> +++ b/lib/mpls_pton.c
>> @@ -7,12 +7,13 @@
>>  #include "utils.h"
>>  
>>  
>> -static int mpls_pton1(const char *name, struct mpls_label *addr)
>> +static int mpls_pton1(const char *name, struct mpls_label *addr,
>> +		      unsigned int maxlabels)
>>  {
>>  	char *endp;
>>  	unsigned count;
>>  
>> -	for (count = 0; count < MPLS_MAX_LABELS; count++) {
>> +	for (count = 0; count < maxlabels; count++) {
>>  		unsigned long label;
>>  
>>  		label = strtoul(name, &endp, 0);
>> @@ -37,17 +38,19 @@ static int mpls_pton1(const char *name, struct mpls_label *addr)
>>  		addr += 1;
>>  	}
>>  	/* The address was too long */
>> +	fprintf(stderr, "Error: too many labels.\n");
>>  	return 0;
>>  }
>>  
>> -int mpls_pton(int af, const char *src, void *addr)
>> +int mpls_pton(int af, const char *src, void *addr, size_t alen)
>>  {
>> +	unsigned int maxlabels = alen / sizeof(struct mpls_label);
> 
> Could ARRAY_SIZE be used?
> 
> Also, I know its only calculated twice, but might it be nicer to
> provide a function or macro to do so? It seems like an ugly thing
> to open code.

I did it this way with intention -- to mpls_pton addr is just a buffer
of a given length. mpls_pton converts the alen into the number of labels
that the buffer can hold and passes that max to mpls_pton1 to do the
heavy lifting.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ