X.25: Fix address field length calculation
Subsystems (3)
PATCH 1/1 X.25: Fix address field length calculation
Addresses are BCD encoded, not ASCII. x25_addr_ntoa got it right.
---
Wrong length calculation leads to rejection of CALL ACCEPT packets.
net/x25/af_x25.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/x25/af_x25.c +1 -1
@@ -98,7 +98,7 @@ int x25_parse_address_block(struct sk_buff *skb, } len = *skb->data; - needed =1 + (len >>4 ) + (len &0x0f ); + needed =1 + ((len >>4 ) + (len &0x0f ) +1 ) /2 ;if (!pskb_may_pull (skb, needed)) {/* packet is too short to hold the addresses it claims
Signature · 1 line
1.8.3.4.71.g0878476
Quoted 1 line · Günther
Addresses are BCD encoded, not ASCII.
x25_addr_ntoagot it right.
[]
Quoted 1 line
Wrong length calculation leads to rejection of CALL ACCEPT packets.
[]
net/x25/af_x25.c
Quoted 1 line
net/x25/af_x25.c +0
-0
[]
net/x25/af_x25.c int x25_parse_address_block(struct sk_buff *skb, · line 100
Quoted 5 lines
net/x25/af_x25.c +1
-1@@ -98,7 +98,7 @@ int x25_parse_address_block(struct sk_buff *skb, } len = *skb->data; - needed =1 + (len >>4 ) + (len &0x0f ); + needed =1 + ((len >>4 ) + (len &0x0f ) +1 ) /2 ;
This calculation looks odd.
Perhaps use bcd.h instead?
Am 15.10.2013 19:29, schrieb Joe Perches:
Quoted 7 lines · Günther
Quoted 1 line
Addresses are BCD encoded, not ASCII.
x25_addr_ntoagot it right.[]
Quoted 1 line
Wrong length calculation leads to rejection of CALL ACCEPT packets.
[]
net/x25/af_x25.c
Quoted 1 line
net/x25/af_x25.c +0
-0[]
Quoted 8 lines
net/x25/af_x25.c int x25_parse_address_block(struct sk_buff *skb, · line 100
Quoted 5 lines
net/x25/af_x25.c +1
-1@@ -98,7 +98,7 @@ int x25_parse_address_block(struct sk_buff *skb, } len = *skb->data; - needed =1 + (len >>4 ) + (len &0x0f ); + needed =1 + ((len >>4 ) + (len &0x0f ) +1 ) /2 ;This calculation looks odd.
Perhaps usebcd.hinstead?
It's just the same calculation as in x25_add_ntoa (last line) and it's used this way by x.25.
Two digits are encoded to one byte and the last byte is padded with 0 if the total number of digits is odd.--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 7 lines · Günther
Quoted 1 line
Addresses are BCD encoded, not ASCII.
x25_addr_ntoagot it right.[]
Quoted 1 line
Wrong length calculation leads to rejection of CALL ACCEPT packets.
[]
net/x25/af_x25.c
Quoted 1 line
net/x25/af_x25.c +0
-0[]
Quoted 7 lines
net/x25/af_x25.c int x25_parse_address_block(struct sk_buff *skb, · line 100
Quoted 5 lines
net/x25/af_x25.c +1
-1@@ -98,7 +98,7 @@ int x25_parse_address_block(struct sk_buff *skb, } len = *skb->data; - needed =1 + (len >>4 ) + (len &0x0f ); + needed =1 + ((len >>4 ) + (len &0x0f ) +1 ) /2 ;This calculation looks odd.
Looks correct to me...
In X.25 the lengths (in digits) of the called and calling addresses are encoded in the high and low nibbles of one byte and then followed by both addresses with a digit in each nibble. If the length of the first address is odd, the second one isn't byte aligned.
David
Sorry for the previous html mail.
This appears to be correct, what length addresses are you getting back in the call accept when this happens?
Quoted 26 lines · David Laight
Quoted 7 lines · Günther
Quoted 1 line
Addresses are BCD encoded, not ASCII.
x25_addr_ntoagot it right.[]
Quoted 1 line
Wrong length calculation leads to rejection of CALL ACCEPT packets.
[]
net/x25/af_x25.c
Quoted 1 line
net/x25/af_x25.c +0
-0[]
Quoted 7 lines
net/x25/af_x25.c int x25_parse_address_block(struct sk_buff *skb, · line 100
Quoted 5 lines
net/x25/af_x25.c +1
-1@@ -98,7 +98,7 @@ int x25_parse_address_block(struct sk_buff *skb, } len = *skb->data; - needed =1 + (len >>4 ) + (len &0x0f ); + needed =1 + ((len >>4 ) + (len &0x0f ) +1 ) /2 ;This calculation looks odd.
Looks correct to me...
In X.25 the lengths (in digits) of the called and calling addresses are encoded in the high and low nibbles of one byte and then followed by both addresses with a digit in each nibble. If the length of the first address is odd, the second one isn't byte aligned.David
E.g. called address 7 digits and caller address 3 digits. Called DCE answering without facilities
gives us this packet (hex):
37 12 34 56 71 23 00
then x25_parse_address_block() tries to pull 1+7+3 = 11 bytes from the packet (with pskb_may_pull())
which only has 7 bytes.
When facilities are included the wrong calculated length has no effect since the facilities make this packet long enough to make pskb_may_pull with wrong number
of bytes succeed. later x25_addr_ntoa() correctly pulls 6 bytes for addresses from the packet.
Am 17.10.2013 13:02, schrieb Andrew Hendry:
Quoted 29 lines
Sorry for the previous html mail.
This appears to be correct, what length addresses are you getting back in the call accept when this happens?Quoted 24 lines · David Laight
Quoted 5 lines · Günther
Quoted 1 line
Addresses are BCD encoded, not ASCII.
x25_addr_ntoagot it right.[]
Quoted 1 line
Wrong length calculation leads to rejection of CALL ACCEPT packets.
[]
Quoted 8 lines
net/x25/af_x25.c
Quoted 1 line
net/x25/af_x25.c +0
-0[]
net/x25/af_x25.c int x25_parse_address_block(struct sk_buff *skb, · line 100
Quoted 5 lines
net/x25/af_x25.c +1
-1@@ -98,7 +98,7 @@ int x25_parse_address_block(struct sk_buff *skb, } len = *skb->data; - needed =1 + (len >>4 ) + (len &0x0f ); + needed =1 + ((len >>4 ) + (len &0x0f ) +1 ) /2 ;This calculation looks odd.
Looks correct to me...
In X.25 the lengths (in digits) of the called and calling addresses are encoded in the high and low nibbles of one byte and then followed by both addresses with a digit in each nibble. If the length of the first address is odd, the second one isn't byte aligned.David
David Miller
maintainerFrom: Kelleter, Günther <[email protected]>
Date: Tue, 15 Oct 2013 14:29:06 +0000
Quoted 5 lines
Addresses are BCD encoded, not ASCII.
x25_addr_ntoagot it right.Signed-off-by Guenther Kelleter <[email protected]>---
Wrong length calculation leads to rejection of CALL ACCEPT packets.
This patch doesn't apply because it was severely corrupted by your email client, turn off all encodings etc. in your client, send a test patch to yourself, and do not submit this patch again until you can successfully apply the patch you receive in those test emails.
Thanks.