Browse Source

[tcp] Avoid potential NULL pointer dereference

Commit ea61075 ("[tcp] Add support for TCP window scaling") introduced
a potential NULL pointer dereference by referring to the connection's
send window scale before checking whether or not the connection is
known.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
55f52bb77a
1 changed files with 3 additions and 1 deletions
  1. 3
    1
      src/net/tcp.c

+ 3
- 1
src/net/tcp.c View File

1155
 	uint16_t csum;
1155
 	uint16_t csum;
1156
 	uint32_t seq;
1156
 	uint32_t seq;
1157
 	uint32_t ack;
1157
 	uint32_t ack;
1158
+	uint16_t raw_win;
1158
 	uint32_t win;
1159
 	uint32_t win;
1159
 	unsigned int flags;
1160
 	unsigned int flags;
1160
 	size_t len;
1161
 	size_t len;
1195
 	tcp = tcp_demux ( ntohs ( tcphdr->dest ) );
1196
 	tcp = tcp_demux ( ntohs ( tcphdr->dest ) );
1196
 	seq = ntohl ( tcphdr->seq );
1197
 	seq = ntohl ( tcphdr->seq );
1197
 	ack = ntohl ( tcphdr->ack );
1198
 	ack = ntohl ( tcphdr->ack );
1198
-	win = ( ntohs ( tcphdr->win ) << tcp->snd_win_scale );
1199
+	raw_win = ntohs ( tcphdr->win );
1199
 	flags = tcphdr->flags;
1200
 	flags = tcphdr->flags;
1200
 	tcp_rx_opts ( tcp, ( ( ( void * ) tcphdr ) + sizeof ( *tcphdr ) ),
1201
 	tcp_rx_opts ( tcp, ( ( ( void * ) tcphdr ) + sizeof ( *tcphdr ) ),
1201
 		      ( hlen - sizeof ( *tcphdr ) ), &options );
1202
 		      ( hlen - sizeof ( *tcphdr ) ), &options );
1226
 
1227
 
1227
 	/* Handle ACK, if present */
1228
 	/* Handle ACK, if present */
1228
 	if ( flags & TCP_ACK ) {
1229
 	if ( flags & TCP_ACK ) {
1230
+		win = ( raw_win << tcp->snd_win_scale );
1229
 		if ( ( rc = tcp_rx_ack ( tcp, ack, win ) ) != 0 ) {
1231
 		if ( ( rc = tcp_rx_ack ( tcp, ack, win ) ) != 0 ) {
1230
 			tcp_xmit_reset ( tcp, st_src, tcphdr );
1232
 			tcp_xmit_reset ( tcp, st_src, tcphdr );
1231
 			goto discard;
1233
 			goto discard;

Loading…
Cancel
Save