127 m_error = String ("recvfrom error: ") + strerror (errno); |
127 m_error = String ("recvfrom error: ") + strerror (errno); |
128 |
128 |
129 return false; |
129 return false; |
130 } |
130 } |
131 |
131 |
|
132 if (length < 4) |
|
133 { |
|
134 m_error = "The server sent a too short packet"; |
|
135 return false; |
|
136 } |
|
137 |
132 unsigned char decodedPacket[MAX_DATAGRAM_LENGTH]; |
138 unsigned char decodedPacket[MAX_DATAGRAM_LENGTH]; |
133 int decodedLength = sizeof decodedPacket; |
139 int decodedLength = sizeof decodedPacket; |
134 HUFFMAN_Decode (reinterpret_cast<unsigned char*> (HuffmanBuffer), |
140 HUFFMAN_Decode (reinterpret_cast<unsigned char*>(HuffmanBuffer), decodedPacket, length, &decodedLength); |
135 decodedPacket, length, &decodedLength); |
|
136 datagram.from.host = ntohl (claddr.sin_addr.s_addr); |
141 datagram.from.host = ntohl (claddr.sin_addr.s_addr); |
137 datagram.from.port = ntohs (claddr.sin_port); |
142 datagram.from.port = ntohs (claddr.sin_port); |
138 datagram.data = Bytestream (decodedPacket, decodedLength); |
143 datagram.data = Bytestream (decodedPacket, decodedLength); |
139 return true; |
144 return true; |
140 } |
145 } |