Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 189851
b: refs/heads/master
c: f5eb917
h: refs/heads/master
i:
  189849: fa7d2a7
  189847: e3a963a
v: v3
  • Loading branch information
John Hughes authored and David S. Miller committed Apr 8, 2010
1 parent ec2b060 commit e38236e
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fd218cf9557b9bf7061365a8fe7020a56d3f767c
refs/heads/master: f5eb917b861828da18dc28854308068c66d1449a
4 changes: 4 additions & 0 deletions trunk/include/net/x25.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ extern int sysctl_x25_clear_request_timeout;
extern int sysctl_x25_ack_holdback_timeout;
extern int sysctl_x25_forward;

extern int x25_parse_address_block(struct sk_buff *skb,
struct x25_address *called_addr,
struct x25_address *calling_addr);

extern int x25_addr_ntoa(unsigned char *, struct x25_address *,
struct x25_address *);
extern int x25_addr_aton(unsigned char *, struct x25_address *,
Expand Down
47 changes: 46 additions & 1 deletion trunk/net/x25/af_x25.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,41 @@ struct compat_x25_subscrip_struct {
};
#endif


int x25_parse_address_block(struct sk_buff *skb,
struct x25_address *called_addr,
struct x25_address *calling_addr)
{
unsigned char len;
int needed;
int rc;

if (skb->len < 1) {
/* packet has no address block */
rc = 0;
goto empty;
}

len = *skb->data;
needed = 1 + (len >> 4) + (len & 0x0f);

if (skb->len < needed) {
/* packet is too short to hold the addresses it claims
to hold */
rc = -1;
goto empty;
}

return x25_addr_ntoa(skb->data, called_addr, calling_addr);

empty:
*called_addr->x25_addr = 0;
*calling_addr->x25_addr = 0;

return rc;
}


int x25_addr_ntoa(unsigned char *p, struct x25_address *called_addr,
struct x25_address *calling_addr)
{
Expand Down Expand Up @@ -921,16 +956,26 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
/*
* Extract the X.25 addresses and convert them to ASCII strings,
* and remove them.
*
* Address block is mandatory in call request packets
*/
addr_len = x25_addr_ntoa(skb->data, &source_addr, &dest_addr);
addr_len = x25_parse_address_block(skb, &source_addr, &dest_addr);
if (addr_len <= 0)
goto out_clear_request;
skb_pull(skb, addr_len);

/*
* Get the length of the facilities, skip past them for the moment
* get the call user data because this is needed to determine
* the correct listener
*
* Facilities length is mandatory in call request packets
*/
if (skb->len < 1)
goto out_clear_request;
len = skb->data[0] + 1;
if (skb->len < len)
goto out_clear_request;
skb_pull(skb,len);

/*
Expand Down
12 changes: 11 additions & 1 deletion trunk/net/x25/x25_facilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities,
struct x25_dte_facilities *dte_facs, unsigned long *vc_fac_mask)
{
unsigned char *p = skb->data;
unsigned int len = *p++;
unsigned int len;

*vc_fac_mask = 0;

Expand All @@ -50,6 +50,14 @@ int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities,
memset(dte_facs->called_ae, '\0', sizeof(dte_facs->called_ae));
memset(dte_facs->calling_ae, '\0', sizeof(dte_facs->calling_ae));

if (skb->len < 1)
return 0;

len = *p++;

if (len >= skb->len)
return -1;

while (len > 0) {
switch (*p & X25_FAC_CLASS_MASK) {
case X25_FAC_CLASS_A:
Expand Down Expand Up @@ -247,6 +255,8 @@ int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk,
memcpy(new, ours, sizeof(*new));

len = x25_parse_facilities(skb, &theirs, dte, &x25->vc_facil_mask);
if (len < 0)
return len;

/*
* They want reverse charging, we won't accept it.
Expand Down
15 changes: 11 additions & 4 deletions trunk/net/x25/x25_in.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ static int x25_queue_rx_frame(struct sock *sk, struct sk_buff *skb, int more)
static int x25_state1_machine(struct sock *sk, struct sk_buff *skb, int frametype)
{
struct x25_address source_addr, dest_addr;
int len;

switch (frametype) {
case X25_CALL_ACCEPTED: {
Expand All @@ -106,11 +107,17 @@ static int x25_state1_machine(struct sock *sk, struct sk_buff *skb, int frametyp
* Parse the data in the frame.
*/
skb_pull(skb, X25_STD_MIN_LEN);
skb_pull(skb, x25_addr_ntoa(skb->data, &source_addr, &dest_addr));
skb_pull(skb,
x25_parse_facilities(skb, &x25->facilities,

len = x25_parse_address_block(skb, &source_addr,
&dest_addr);
if (len > 0)
skb_pull(skb, len);

len = x25_parse_facilities(skb, &x25->facilities,
&x25->dte_facilities,
&x25->vc_facil_mask));
&x25->vc_facil_mask);
if (len > 0)
skb_pull(skb, len);
/*
* Copy any Call User Data.
*/
Expand Down

0 comments on commit e38236e

Please sign in to comment.