@@ -147,6 +147,7 @@ static int is_ssh_protocol(const char *p, ssize_t len, struct sslhcfg_protocols_
147147#define OVPN_OPCODE_MASK 0xF8
148148#define OVPN_CONTROL_HARD_RESET_CLIENT_V1 (0x01 << 3)
149149#define OVPN_CONTROL_HARD_RESET_CLIENT_V2 (0x07 << 3)
150+ #define OVPN_CONTROL_HARD_RESET_CLIENT_V3 (0x0A << 3)
150151#define OVPN_HMAC_128 16
151152#define OVPN_HMAC_160 20
152153#define OVPN_HARD_RESET_PACKET_ID_OFFSET (hmac_size ) (9 + hmac_size)
@@ -165,8 +166,12 @@ static int is_openvpn_protocol (const char*p,ssize_t len, struct sslhcfg_protoco
165166 if (len < 1 )
166167 return PROBE_NEXT ;
167168
169+ printf ("opcode: %d\n" , (p [0 ] & OVPN_OPCODE_MASK ) >> 3 );
170+
168171 if ((p [0 ] & OVPN_OPCODE_MASK ) != OVPN_CONTROL_HARD_RESET_CLIENT_V1 &&
169- (p [0 ] & OVPN_OPCODE_MASK ) != OVPN_CONTROL_HARD_RESET_CLIENT_V2 )
172+ (p [0 ] & OVPN_OPCODE_MASK ) != OVPN_CONTROL_HARD_RESET_CLIENT_V2 &&
173+ (p [0 ] & OVPN_OPCODE_MASK ) != OVPN_CONTROL_HARD_RESET_CLIENT_V3
174+ )
170175 return PROBE_NEXT ;
171176
172177 /* The detection pattern above may not be reliable enough.
@@ -177,12 +182,18 @@ static int is_openvpn_protocol (const char*p,ssize_t len, struct sslhcfg_protoco
177182 if (len <= OVPN_HARD_RESET_PACKET_ID_OFFSET (OVPN_HMAC_128 ) + sizeof (uint32_t ))
178183 return PROBE_NEXT ;
179184
180- if (ntohl (* (uint32_t * )(p + OVPN_HARD_RESET_PACKET_ID_OFFSET (OVPN_HMAC_128 ))) <= 5u )
185+ uint32_t i ;
186+ /* OVPN_HMAC_128 is unaligned, which requires special care e.g. on ARM */
187+ memcpy (& i , (p + OVPN_HARD_RESET_PACKET_ID_OFFSET (OVPN_HMAC_128 )), sizeof (i ));
188+ i = ntohl (i );
189+ if (i <= 5u )
181190 return PROBE_MATCH ;
182191
183192 if (len <= OVPN_HARD_RESET_PACKET_ID_OFFSET (OVPN_HMAC_160 ) + sizeof (uint32_t ))
184193 return PROBE_NEXT ;
185194
195+ memcpy (& i , (p + OVPN_HARD_RESET_PACKET_ID_OFFSET (OVPN_HMAC_160 )), sizeof (i ));
196+ i = ntohl (i );
186197 if (ntohl (* (uint32_t * )(p + OVPN_HARD_RESET_PACKET_ID_OFFSET (OVPN_HMAC_160 ))) <= 5u )
187198 return PROBE_MATCH ;
188199
0 commit comments