diff mbox

conntrack: made the protocol option value case insensitive

Message ID 1435227145-15554-1-git-send-email-pfeiffer.szilard@balabit.hu
State Changes Requested
Delegated to: Pablo Neira
Headers show

Commit Message

pfeiffer.szilard@balabit.hu June 25, 2015, 10:12 a.m. UTC
From: Szilárd Pfeiffer <pfeiffer.szilard@balabit.hu>

Extensions register protocols by lowercase protocol name, but value of
proto command line option may be uppercase. Extension related options
cannot be used when protocol name comparision fails.

Signed-off-by: Szilárd Pfeiffer <pfeiffer.szilard@balabit.hu>
---
 src/conntrack.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Florian Westphal June 26, 2015, 7:19 a.m. UTC | #1
pfeiffer.szilard@balabit.hu <pfeiffer.szilard@balabit.hu> wrote:
> From: Szilárd Pfeiffer <pfeiffer.szilard@balabit.hu>
> 
> Extensions register protocols by lowercase protocol name, but value of
> proto command line option may be uppercase. Extension related options
> cannot be used when protocol name comparision fails.
> 
> Signed-off-by: Szilárd Pfeiffer <pfeiffer.szilard@balabit.hu>
> ---
>  src/conntrack.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/conntrack.c b/src/conntrack.c
> index f7d37fb..b1a2589 100644
> --- a/src/conntrack.c
> +++ b/src/conntrack.c
> @@ -555,6 +555,12 @@ static struct ctproto_handler *findproto(char *name, int *pnum)
>  	/* using the protocol name for an unsupported protocol? */
>  	if ((pent = getprotobyname(name))) {
>  		*pnum = pent->p_proto;

Why not use strcasecmp to check the proto_list?
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pablo Neira Ayuso July 2, 2015, 4:59 p.m. UTC | #2
On Fri, Jun 26, 2015 at 09:19:21AM +0200, Florian Westphal wrote:
> pfeiffer.szilard@balabit.hu <pfeiffer.szilard@balabit.hu> wrote:
> > From: Szilárd Pfeiffer <pfeiffer.szilard@balabit.hu>
> > 
> > Extensions register protocols by lowercase protocol name, but value of
> > proto command line option may be uppercase. Extension related options
> > cannot be used when protocol name comparision fails.
> > 
> > Signed-off-by: Szilárd Pfeiffer <pfeiffer.szilard@balabit.hu>
> > ---
> >  src/conntrack.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/src/conntrack.c b/src/conntrack.c
> > index f7d37fb..b1a2589 100644
> > --- a/src/conntrack.c
> > +++ b/src/conntrack.c
> > @@ -555,6 +555,12 @@ static struct ctproto_handler *findproto(char *name, int *pnum)
> >  	/* using the protocol name for an unsupported protocol? */
> >  	if ((pent = getprotobyname(name))) {
> >  		*pnum = pent->p_proto;
> 
> Why not use strcasecmp to check the proto_list?

Please, address Florian's feedback and resubmit, thanks.

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
pfeiffer.szilard@balabit.hu July 2, 2015, 10:53 p.m. UTC | #3
On 2015-06-26 09:19, Florian Westphal wrote:
> pfeiffer.szilard@balabit.hu <pfeiffer.szilard@balabit.hu> wrote:
>> From: Szilárd Pfeiffer <pfeiffer.szilard@balabit.hu>
>>
>> Extensions register protocols by lowercase protocol name, but value of
>> proto command line option may be uppercase. Extension related options
>> cannot be used when protocol name comparision fails.
>>
>> Signed-off-by: Szilárd Pfeiffer <pfeiffer.szilard@balabit.hu>
>> ---
>>  src/conntrack.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/src/conntrack.c b/src/conntrack.c
>> index f7d37fb..b1a2589 100644
>> --- a/src/conntrack.c
>> +++ b/src/conntrack.c
>> @@ -555,6 +555,12 @@ static struct ctproto_handler *findproto(char *name, int *pnum)
>>  	/* using the protocol name for an unsupported protocol? */
>>  	if ((pent = getprotobyname(name))) {
>>  		*pnum = pent->p_proto;
> Why not use strcasecmp to check the proto_list?
>
I have just realized that iptables ignores case while checking value of
--protocol parameter, so the conntrack tool should do it in the same way.

I remake the patch. Thanks for your feedback.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/conntrack.c b/src/conntrack.c
index f7d37fb..b1a2589 100644
--- a/src/conntrack.c
+++ b/src/conntrack.c
@@ -555,6 +555,12 @@  static struct ctproto_handler *findproto(char *name, int *pnum)
 	/* using the protocol name for an unsupported protocol? */
 	if ((pent = getprotobyname(name))) {
 		*pnum = pent->p_proto;
+		list_for_each_entry(cur, &proto_list, head) {
+			if (cur->protonum == pent->p_proto) {
+				*pnum = cur->protonum;
+				return cur;
+			}
+		}
 		return &ct_proto_unknown;
 	}
 	/* using a protocol number? */