]> git.ipfire.org Git - thirdparty/hostap.git/log
thirdparty/hostap.git
10 years agoFix ANQP_GET/HS20_GET_ANQP parsing to skip space after address
Jouni Malinen [Wed, 10 Dec 2014 23:41:48 +0000 (01:41 +0200)] 
Fix ANQP_GET/HS20_GET_ANQP parsing to skip space after address

The space following the BSSID was not skipped properly if the following
parameter started with the "hs20:" prefix. For other cases, atoi() ended
up ignoring the space, but it is cleaner to skip it anyway for all
cases.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: INTERWORKING_CONNECT with invalid parameter
Jouni Malinen [Wed, 10 Dec 2014 23:29:33 +0000 (01:29 +0200)] 
tests: INTERWORKING_CONNECT with invalid parameter

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Optimize p2p_persistent test cases
Jouni Malinen [Wed, 10 Dec 2014 23:25:14 +0000 (01:25 +0200)] 
tests: Optimize p2p_persistent test cases

Number of unnecessary scan iterations can removed from these test cases
by specifying a single channel.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional P2P_REMOVE_CLIENT coverage
Jouni Malinen [Wed, 10 Dec 2014 22:03:01 +0000 (00:03 +0200)] 
tests: Additional P2P_REMOVE_CLIENT coverage

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional coverage for P2P_EXT_LISTEN
Jouni Malinen [Wed, 10 Dec 2014 21:47:04 +0000 (23:47 +0200)] 
tests: Additional coverage for P2P_EXT_LISTEN

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional P2P_PRESENCE_REQ coverage
Jouni Malinen [Wed, 10 Dec 2014 21:35:29 +0000 (23:35 +0200)] 
tests: Additional P2P_PRESENCE_REQ coverage

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: ProxyARP ARP processing
Jouni Malinen [Wed, 10 Dec 2014 17:25:35 +0000 (19:25 +0200)] 
tests: ProxyARP ARP processing

This verifies processing of various ARP messages at an AP that enables
ProxyARP. All the validation steps have not yet been scripted, i.e., the
sniffer traces need manual analysis for full coverage.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: Additional P2P_SET coverage
Jouni Malinen [Wed, 10 Dec 2014 00:01:04 +0000 (02:01 +0200)] 
tests: Additional P2P_SET coverage

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: P2P cross connection
Jouni Malinen [Tue, 9 Dec 2014 23:59:47 +0000 (01:59 +0200)] 
tests: P2P cross connection

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoP2P: Allow cross connection on the parent interface
Jouni Malinen [Tue, 9 Dec 2014 23:54:27 +0000 (01:54 +0200)] 
P2P: Allow cross connection on the parent interface

Previously, any P2P capable interface was skipped in cross connection
uplink consideration. However, this ends up skipping more or less all
nl80211-based driver cases now since they mark the main interface P2P
capable. Relax this rule to allow the parent interface to be used as the
non-P2P station interface for cross connection purposes.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional P2P_PEER coverage
Jouni Malinen [Tue, 9 Dec 2014 22:46:11 +0000 (00:46 +0200)] 
tests: Additional P2P_PEER coverage

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoOpenSSL: Simplify EAP-FAST peer workaround
Jouni Malinen [Tue, 9 Dec 2014 21:55:41 +0000 (23:55 +0200)] 
OpenSSL: Simplify EAP-FAST peer workaround

Commit d4913c585ec9b62a667473878a7fd7d8600d3388 ('OpenSSL: Fix EAP-FAST
peer regression') introduced a workaround to use a new SSL_CTX instance
set for TLSv1_method() when using EAP-FAST. While that works, it is
unnecessarily complex since there is not really a need to use a separate
SSL_CTX to be able to do that. Instead, simply use SSL_set_ssl_method()
to update the ssl_method for the SSL instance. In practice, this commit
reverts most of the tls_openssl.c changes from that earlier commit and
adds that single call into tls_connection_set_params() based on EAP-FAST
flag.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Verify that EAP-FAST PAC and TLS session ticket was used
Jouni Malinen [Tue, 9 Dec 2014 21:47:47 +0000 (23:47 +0200)] 
tests: Verify that EAP-FAST PAC and TLS session ticket was used

This provides a regression test that would have caught the recent
issue with tls_openssl.c change breaking EAP-FAST.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoAdd tls_session_reused=<0/1> into EAP peer TLS status
Jouni Malinen [Tue, 9 Dec 2014 21:41:09 +0000 (23:41 +0200)] 
Add tls_session_reused=<0/1> into EAP peer TLS status

This can be used to determine whether the last TLS-based EAP
authentication instance re-used a previous session (e.g., TLS session
resumption or EAP-FAST session ticket).

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional P2P_GROUP_ADD coverage
Jouni Malinen [Tue, 9 Dec 2014 21:03:27 +0000 (23:03 +0200)] 
tests: Additional P2P_GROUP_ADD coverage

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Add QCA vendor specific query of device/driver features
Chet Lanctot [Sat, 6 Dec 2014 00:48:23 +0000 (16:48 -0800)] 
nl80211: Add QCA vendor specific query of device/driver features

This commit introduces a QCA vendor command that allows interrogation of
the vendor-specific features supported by the device/driver. Currently
the only defined feature is the ability to offload key management.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agoOpenSSL: Fix EAP-FAST peer regression
Jouni Malinen [Tue, 9 Dec 2014 13:57:03 +0000 (15:57 +0200)] 
OpenSSL: Fix EAP-FAST peer regression

Commit 35efa2479ff19c3f13e69dc50d2708ce79a99beb ('OpenSSL: Allow TLS
v1.1 and v1.2 to be negotiated by default') changed from using
TLSv1_method() to SSLv23_method() to allow negotiation of TLS v1.0,
v1.1, and v1.2.

Unfortunately, it looks like EAP-FAST does not work with this due to
OpenSSL not allowing ClientHello extensions to be configured with
SSL_set_session_ticket_ext() when SSLv23_method() is used. Work around
this regression by initiating a separate SSL_CTX instance for EAP-FAST
phase 1 needs with TLSv1_method() while leaving all other EAP cases
using TLS to work with the new default that allows v1.1 and v1.2 to be
negotiated. This is not ideal and will hopefully get fixed in the future
with a new OpenSSL method, but until that time, this can be used allow
other methods use newer TLS versions while still allowing EAP-FAST to be
used even if it remains to be constraint to TLS v1.0 only.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoFix OpenSSL 0.9.8za patch for EAP-FAST support
Jouni Malinen [Tue, 9 Dec 2014 11:19:22 +0000 (13:19 +0200)] 
Fix OpenSSL 0.9.8za patch for EAP-FAST support

OpenSSL 0.9.8za added a fix for CVE-2014-0224 and the original fix broke
EAP-FAST support due to forgotten SSL3_FLAGS_CCS_OK marking for
tls_session_secret_cb. Fix for this regression was added into OpenSSL
1.x and newer. The same fix is needed in this backport patch for
0.9.8za.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoTLS: Add new cipher suites to tls_get_cipher()
Jouni Malinen [Tue, 9 Dec 2014 10:31:08 +0000 (12:31 +0200)] 
TLS: Add new cipher suites to tls_get_cipher()

This fixes EAP-FAST server side issues for anonymous provisioning when
using the internal TLS implementation.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoOpenSSL: Remove support for the old EAP-FAST interface
Jouni Malinen [Tue, 9 Dec 2014 10:05:03 +0000 (12:05 +0200)] 
OpenSSL: Remove support for the old EAP-FAST interface

Commit f5fa824e9a86940835e30a5a0b1fd3d8a7c4c640 ('Update OpenSSL 0.9.8
patch for EAP-FAST support') changed the OpenSSL 0.9.8 patch to support
the new API that was introduced in OpenSSL 1.0.0 for EAP-FAST. As such,
there should be no valid users of the old API anymore and tls_openssl.c
can be cleaned up to use only the new API.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoMACsec: Update protect frames and replay on reauthentication
Xiaofei Shen [Tue, 9 Dec 2014 14:20:31 +0000 (16:20 +0200)] 
MACsec: Update protect frames and replay on reauthentication

Some cases like ifconfig down/up may require MACsec restart. To make
sure the appropriate protect frames and replay parameters get configured
in cases where the interface was down, set these parameters from KaY
configuration to the driver before creating a new transmit SC. This
allows MACsec functionality to recover automatically on such restart.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: Invitation Request retry and duplicated response
Jouni Malinen [Mon, 8 Dec 2014 23:56:57 +0000 (01:56 +0200)] 
tests: Invitation Request retry and duplicated response

This verifies that the corner case of a duplicated, retransmitted
Invitation Response frame ends up being dropped instead of being
processed twice for the case of Invitation Request getting resend with
social channel as an operating channel in case of no common channels
found.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agoP2P: Check Invitation Response dialog token match for resend case
Sunil Dutt [Mon, 8 Dec 2014 09:41:16 +0000 (15:11 +0530)] 
P2P: Check Invitation Response dialog token match for resend case

Commit ac330cfd87397a1a01e697984f3944f427e88dad ('P2P: Reinvite with
social operation channel if no common channels') introduced a mechamisn
to reinvite a peer during a persistent group reinvocation from a GO with
a different operating channel proposal. This mechanism can fail if the
inviting device (GO) ends up getting a retransmitted, duplicated
Invitation Response frame processed second time while waiting for the
response to the retried Invitation Request (using one of the social
channels as the operating channel). IEEE 802.11 duplicate frame
detection mechanisms are supposed to prevent this type of sequence, but
not all drivers support those rules properly for pre-association frames,
including P2P Public Action frames.

Work around this issue by checking that the dialog token in the
Invitation Response frame matches the one from the last Invitation
Request if the special invitation retry mechanism is used. This is safer
to do now than to enable dialog token matching for all invitation cases.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agonl80211: Add frame control and sequence control field in RX frame debug
Jouni Malinen [Mon, 8 Dec 2014 23:19:20 +0000 (01:19 +0200)] 
nl80211: Add frame control and sequence control field in RX frame debug

This makes it easier to debug issues related to duplicated management
frames on receive path.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional P2P SD coverage
Jouni Malinen [Mon, 8 Dec 2014 16:54:27 +0000 (18:54 +0200)] 
tests: Additional P2P SD coverage

This adds P2P_SERV_DISC_REQ, P2P_SERVICE_ADD, and P2P_SERVICE_DEL error
cases and P2P_SERVICE_FLUSH and P2P_SERC_DISC_EXTERNAL testing.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: P2P_GET_PASSPHRASE in P2P Client mode
Jouni Malinen [Mon, 8 Dec 2014 19:10:03 +0000 (21:10 +0200)] 
tests: P2P_GET_PASSPHRASE in P2P Client mode

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Invalid P2P_INVITE parameters
Jouni Malinen [Mon, 8 Dec 2014 17:46:00 +0000 (19:46 +0200)] 
tests: Invalid P2P_INVITE parameters

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Invalid P2P_REJECT command
Jouni Malinen [Mon, 8 Dec 2014 17:34:49 +0000 (19:34 +0200)] 
tests: Invalid P2P_REJECT command

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional coverage for P2P_PROV_DISC
Jouni Malinen [Mon, 8 Dec 2014 16:42:16 +0000 (18:42 +0200)] 
tests: Additional coverage for P2P_PROV_DISC

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: P2P_LISTEN while interface is disabled
Jouni Malinen [Mon, 8 Dec 2014 16:25:05 +0000 (18:25 +0200)] 
tests: P2P_LISTEN while interface is disabled

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional P2P_CONNECT coverage
Jouni Malinen [Mon, 8 Dec 2014 16:21:48 +0000 (18:21 +0200)] 
tests: Additional P2P_CONNECT coverage

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional P2P_FIND parameter coverage
Jouni Malinen [Mon, 8 Dec 2014 15:56:47 +0000 (17:56 +0200)] 
tests: Additional P2P_FIND parameter coverage

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional BSS and BSS_FLUSH ctrl_iface command coverage
Jouni Malinen [Mon, 8 Dec 2014 15:47:06 +0000 (17:47 +0200)] 
tests: Additional BSS and BSS_FLUSH ctrl_iface command coverage

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoClear wpa_s->disconnected on ctrl_iface FLUSH
Jouni Malinen [Mon, 8 Dec 2014 14:22:13 +0000 (16:22 +0200)] 
Clear wpa_s->disconnected on ctrl_iface FLUSH

This is needed to get into more consistent state after the FLUSH
command. DISCONNECT followed by FLUSH could result in
wpa_s->disconnected being left to 1 and this resulted in a test failure,
e.g., when running wpas_ctrl_dup_network followed by
wpas_ctrl_enable_disable_network where the latter was expecting
ENABLE_NETWORK on a disabled network to connect automatically and that
does not happen if wpa_s->disconnected == 1.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agonl80211: Try to unmask 11b rates again on next connection request
Jouni Malinen [Mon, 8 Dec 2014 14:10:46 +0000 (16:10 +0200)] 
nl80211: Try to unmask 11b rates again on next connection request

It is possible for unmasking of 11b rates to fail if a P2P group is
terminated while the netdev is down (e.g., due to rfkill block). This
could result in the 11b TX rates being left masked for non-P2P
operations. This would be particularly unfortunate for channel 14 use
since OFDM rates are not allowed on channel 14 and only OFDM rates were
configured P2P. This issue showed up, e.g., when running hwsim test case
rfkill_autogo followed by ap_wps_conf_chan14.

It may be possible to allow the failed operation in cfg80211/mac80211,
but it looks better to work around this on wpa_supplicant side as well.
Try to unmask the 11b rates again on the next connection request if the
rate unmasking operation had failed.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agonl80211: Add more debug prints for 11b rate disabling and re-enabling
Jouni Malinen [Mon, 8 Dec 2014 14:01:51 +0000 (16:01 +0200)] 
nl80211: Add more debug prints for 11b rate disabling and re-enabling

This makes it easier to debug issues related to TX rate masking for P2P
use cases (and unmasking for non-P2P).

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agoCheck os_snprintf() result more consistently - more checks
Jouni Malinen [Sun, 7 Dec 2014 13:45:02 +0000 (15:45 +0200)] 
Check os_snprintf() result more consistently - more checks

Add more os_snprintf() result validation checks.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently
Jouni Malinen [Sat, 6 Dec 2014 19:40:31 +0000 (21:40 +0200)] 
Check os_snprintf() result more consistently

While these are using practically large enoungh buffer sizes, it is
better to be more consistent with checking os_snprintf() return value.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently - manual
Jouni Malinen [Sun, 7 Dec 2014 10:52:59 +0000 (12:52 +0200)] 
Check os_snprintf() result more consistently - manual

This converts os_snprintf() result validation cases to use
os_snprintf_error() for cases that were note covered by spatch and
semantic patches.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently - automatic 3
Jouni Malinen [Mon, 8 Dec 2014 09:22:52 +0000 (11:22 +0200)] 
Check os_snprintf() result more consistently - automatic 3

This converts os_snprintf() result validation cases to use
os_snprintf_error() where the comparison was 'res > size' instead of
'res >= size - 1'. These changes were done automatically with spatch
using the following semantic patch:

@@
identifier E1;
expression E2,E3,E4,E5,E6;
statement S1;
@@

(
  E1 = os_snprintf(E2, E3, ...);
|
  int E1 = os_snprintf(E2, E3, ...);
|
  if (E5)
E1 = os_snprintf(E2, E3, ...);
  else
E1 = os_snprintf(E2, E3, ...);
|
  if (E5)
E1 = os_snprintf(E2, E3, ...);
  else if (E6)
E1 = os_snprintf(E2, E3, ...);
  else
E1 = 0;
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
return -1;
  }
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else if (E6) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
return -1;
  }
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
E1 = os_snprintf(E2, E3, ...);
  }
)
? os_free(E4);
- if (E1 < 0 || (size_t) E1 >= E3 - 1)
+ if (os_snprintf_error(E3, E1))
(
  S1
|
{ ... }
)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently - automatic 2
Jouni Malinen [Mon, 8 Dec 2014 09:18:39 +0000 (11:18 +0200)] 
Check os_snprintf() result more consistently - automatic 2

This converts os_snprintf() result validation cases to use
os_snprintf_error() where the comparison was 'res > size' instead of
'res >= size'. These changes were done automatically with spatch using
the following semantic patch:

@@
identifier E1;
expression E2,E3,E4,E5,E6;
statement S1;
@@

(
  E1 = os_snprintf(E2, E3, ...);
|
  int E1 = os_snprintf(E2, E3, ...);
|
  if (E5)
E1 = os_snprintf(E2, E3, ...);
  else
E1 = os_snprintf(E2, E3, ...);
|
  if (E5)
E1 = os_snprintf(E2, E3, ...);
  else if (E6)
E1 = os_snprintf(E2, E3, ...);
  else
E1 = 0;
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
return -1;
  }
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else if (E6) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
return -1;
  }
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
E1 = os_snprintf(E2, E3, ...);
  }
)
? os_free(E4);
- if (E1 < 0 || \( E1 > E3 \| (size_t) E1 > E3 \| E1 > (int) E3 \))
+ if (os_snprintf_error(E3, E1))
(
  S1
|
{ ... }
)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently - automatic 1
Jouni Malinen [Mon, 8 Dec 2014 09:15:51 +0000 (11:15 +0200)] 
Check os_snprintf() result more consistently - automatic 1

This converts os_snprintf() result validation cases to use
os_snprintf_error() where the exact rule used in os_snprintf_error() was
used. These changes were done automatically with spatch using the
following semantic patch:

@@
identifier E1;
expression E2,E3,E4,E5,E6;
statement S1;
@@

(
  E1 = os_snprintf(E2, E3, ...);
|
  int E1 = os_snprintf(E2, E3, ...);
|
  if (E5)
E1 = os_snprintf(E2, E3, ...);
  else
E1 = os_snprintf(E2, E3, ...);
|
  if (E5)
E1 = os_snprintf(E2, E3, ...);
  else if (E6)
E1 = os_snprintf(E2, E3, ...);
  else
E1 = 0;
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
return -1;
  }
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else if (E6) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
return -1;
  }
|
  if (E5) {
...
E1 = os_snprintf(E2, E3, ...);
  } else {
...
E1 = os_snprintf(E2, E3, ...);
  }
)
? os_free(E4);
- if (E1 < 0 || \( E1 >= E3 \| (size_t) E1 >= E3 \| (unsigned int) E1 >= E3 \| E1 >= (int) E3 \))
+ if (os_snprintf_error(E3, E1))
(
  S1
|
{ ... }
)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently - success case
Jouni Malinen [Sun, 7 Dec 2014 10:15:34 +0000 (12:15 +0200)] 
Check os_snprintf() result more consistently - success case

This converts os_snprintf() result validation cases to use
os_snprintf_error() in cases where success condition was used to execute
a step. These changes were done automatically with spatch using the
following semantic patch:

@@
expression E1,E2,E3;
statement S1;
@@

  E1 = os_snprintf(E2, E3, ...);
- if (\( E1 >= 0 \| E1 > 0 \) && \( (size_t) E1 < E3 \| E1 < (int) E3 \| E1 < E3 \))
+ if (!os_snprintf_error(E3, E1))
  S1

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoCheck os_snprintf() result more consistently - maximum length
Jouni Malinen [Sun, 7 Dec 2014 10:11:13 +0000 (12:11 +0200)] 
Check os_snprintf() result more consistently - maximum length

This adds verification of os_snprintf() result against the maximum
buffer length. These changes were done automatically with spatch
using the following semantic patch:

@@
expression E1,E2,E3;
statement S1;
@@

  E1 = os_snprintf(E2, E3, ...);
- if (\( E1 < 0 \| E1 <= 0 \))
+ if (os_snprintf_error(E3, E1))
(
  S1
|
{ ... }
)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoAdd os_snprintf_error() helper
Jouni Malinen [Sat, 6 Dec 2014 22:03:28 +0000 (00:03 +0200)] 
Add os_snprintf_error() helper

This can be used to check os_snprintf() return value more consistently.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoUse os_zalloc() instead of os_malloc() and os_memset()
Jouni Malinen [Sun, 7 Dec 2014 15:16:58 +0000 (17:16 +0200)] 
Use os_zalloc() instead of os_malloc() and os_memset()

Automatically updated with spatch and the following semantic patch:

@@
expression X;
expression E1;
statement S;
@@

- X = os_malloc(E1);
+ X = os_zalloc(E1);
(
  if (X == NULL) {
...
  }
- os_memset(X, 0, E1);
|
  if (X == NULL)
S
- os_memset(X, 0, E1);
)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoUse os_calloc() instead of os_zalloc()
Jouni Malinen [Sun, 7 Dec 2014 14:51:38 +0000 (16:51 +0200)] 
Use os_calloc() instead of os_zalloc()

Automatic changes with spatch using the following semantic patch:

@@
constant C;
type T;
@@

- os_zalloc(C*sizeof(T))
+ os_calloc(C,sizeof(T))

@@
expression E;
type T;
@@

- os_zalloc((E)*sizeof(T))
+ os_calloc(E,sizeof(T))

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Optimize WPS tests by avoiding full scan
Jouni Malinen [Sun, 7 Dec 2014 23:37:39 +0000 (01:37 +0200)] 
tests: Optimize WPS tests by avoiding full scan

A single channel scan just before WPS_REG, WPS_PBC, and WPS_PIN commands
can be used to avoid having to run a full scan. This saves significant
amount of time in the WPS test cases.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoWPS: Start EAPOL immediately even without WPA on WPS association
Jouni Malinen [Sun, 7 Dec 2014 23:25:26 +0000 (01:25 +0200)] 
WPS: Start EAPOL immediately even without WPA on WPS association

Previously, the immediate EAPOL authenticator startup was scheduled
without having received EAPOL-Start only for the case where WPA/WPA2 was
enabled. This can be extended to speed up non-WPA/WPA2 cases as well if
the STA includes WPS IE in Association Request frame.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: P2P_GET_PASSPHRASE
Jouni Malinen [Sun, 7 Dec 2014 23:04:19 +0000 (01:04 +0200)] 
tests: P2P_GET_PASSPHRASE

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional GET_CAPABILITY coverage
Jouni Malinen [Sun, 7 Dec 2014 22:42:42 +0000 (00:42 +0200)] 
tests: Additional GET_CAPABILITY coverage

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: SAVE_CONFIG error cases
Jouni Malinen [Sun, 7 Dec 2014 22:30:18 +0000 (00:30 +0200)] 
tests: SAVE_CONFIG error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Multiple networks and cred removal
Jouni Malinen [Sun, 7 Dec 2014 22:22:39 +0000 (00:22 +0200)] 
tests: Multiple networks and cred removal

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional DUP_NETWORK coverage
Jouni Malinen [Sun, 7 Dec 2014 22:05:55 +0000 (00:05 +0200)] 
tests: Additional DUP_NETWORK coverage

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoFix DUP_NETWORK debug print on error case
Jouni Malinen [Sun, 7 Dec 2014 21:58:06 +0000 (23:58 +0200)] 
Fix DUP_NETWORK debug print on error case

Incorrect network id was printed in debug output if DUP_NETWORK
destination network was not found.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Add missing test descriptions
Jouni Malinen [Sun, 7 Dec 2014 21:48:05 +0000 (23:48 +0200)] 
tests: Add missing test descriptions

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: wpa_supplicant ctrl_iface mesh command error cases
Jouni Malinen [Sun, 7 Dec 2014 21:45:05 +0000 (23:45 +0200)] 
tests: wpa_supplicant ctrl_iface mesh command error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoRemove unnecessary ctrl_iface command check
Jouni Malinen [Sun, 7 Dec 2014 21:43:21 +0000 (23:43 +0200)] 
Remove unnecessary ctrl_iface command check

MESH_GROUP_REMOVE always passes in the cmd pointer, so this cannot
really be NULL.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Additional coverage for SCAN_RESULTS and BSS entry flags
Jouni Malinen [Sun, 7 Dec 2014 21:27:45 +0000 (23:27 +0200)] 
tests: Additional coverage for SCAN_RESULTS and BSS entry flags

This increases wpa_supplicant_ie_txt(), print_bss_info(), and
wpa_supplicant_ctrl_iface_scan_result() testing coverage to include the
previously missing key management options.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agobase64: Try to avoid static analyzer warning (part 2)
Jouni Malinen [Sun, 7 Dec 2014 20:02:57 +0000 (22:02 +0200)] 
base64: Try to avoid static analyzer warning (part 2)

Shift right on unsigned char limits the value to 0..63 which is within
bounds for base64_table[]. Anyway, some static analyzers do not seem to
understand that. See if an otherwise unnecessary masking gets rid of
false warnings. (CID 62858)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoRemove unnecessary ctrl_iface cmd check
Jouni Malinen [Sun, 7 Dec 2014 16:20:23 +0000 (18:20 +0200)] 
Remove unnecessary ctrl_iface cmd check

This pointer cannot be NULL sicne it is called only from this file and
with a valid pointer to the received command.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: wpa_supplicant ctrl_iface BSSID command error case
Jouni Malinen [Sun, 7 Dec 2014 16:19:12 +0000 (18:19 +0200)] 
tests: wpa_supplicant ctrl_iface BSSID command error case

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Check STATUS mode field during P2P group formation
Jouni Malinen [Sun, 7 Dec 2014 16:17:31 +0000 (18:17 +0200)] 
tests: Check STATUS mode field during P2P group formation

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: wpa_supplicant ctrl_iface CTRL-RSP-
Jouni Malinen [Sun, 7 Dec 2014 16:10:20 +0000 (18:10 +0200)] 
tests: wpa_supplicant ctrl_iface CTRL-RSP-

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: IBSS_RSN control interface command
Jouni Malinen [Sun, 7 Dec 2014 15:57:28 +0000 (17:57 +0200)] 
tests: IBSS_RSN control interface command

This verifies that IBSS_RSN <peer> return OK for the case where a valid
and already connection peer address is given.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: wpa_supplicant WPS_AP_PIN random PIN timeout and error caes
Jouni Malinen [Sun, 7 Dec 2014 15:47:02 +0000 (17:47 +0200)] 
tests: wpa_supplicant WPS_AP_PIN random PIN timeout and error caes

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: More coverage for WPS NFC error and uncommon cases
Jouni Malinen [Sun, 7 Dec 2014 15:36:22 +0000 (17:36 +0200)] 
tests: More coverage for WPS NFC error and uncommon cases

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Fix a typo in an error message
Jouni Malinen [Sun, 7 Dec 2014 15:24:38 +0000 (17:24 +0200)] 
tests: Fix a typo in an error message

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Remove test names from VM command with parallel-vm.py
Jouni Malinen [Sun, 7 Dec 2014 13:31:38 +0000 (15:31 +0200)] 
tests: Remove test names from VM command with parallel-vm.py

There is no need to pass the test case names to the VMs when using
parallel-vm.py. Removing those from the command line helps in avoiding
kernel panic if maximum number of kernel parameters limit is hit.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agobase64: Try to avoid static analyzer warning
Jouni Malinen [Sat, 6 Dec 2014 17:03:52 +0000 (19:03 +0200)] 
base64: Try to avoid static analyzer warning

Shift right on unsigned char limits the value to 0..63 which is within
bounds for base64_table[]. Anyway, some static analyzers do not seem to
understand that. See if an otherwise unnecessary masking gets rid of
false warnings. (CID 62858)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoInterworking: Make bounds checking easier for static analyzers
Jouni Malinen [Sat, 6 Dec 2014 16:51:23 +0000 (18:51 +0200)] 
Interworking: Make bounds checking easier for static analyzers

'num * 5 > end - pos' handles bounds checking a bit more efficiently,
but apparently that is not clear enough for all static analyzers.
Replace with 'num > left / 5' to avoid false reports. (CID 68117)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoTLS: Reorder length bounds checking to avoid static analyzer warning
Jouni Malinen [Sat, 6 Dec 2014 16:34:23 +0000 (18:34 +0200)] 
TLS: Reorder length bounds checking to avoid static analyzer warning

For some reason, "pos + len > end" is not clear enough, but "len > end -
pos" is recognized. Use that to get rid of a false positive from a
static analyzer (CID 72697).

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoEAP-SIM DB: Make recv() null termination easier for static analyzers
Jouni Malinen [Sat, 6 Dec 2014 16:28:00 +0000 (18:28 +0200)] 
EAP-SIM DB: Make recv() null termination easier for static analyzers

For some reason, the previous version was not understood to be null
terminating the buffer from recv(). It was doing this fine, though. Try
to use a bit more simpler design in hopes of getting static analyzers to
understand this. (CID 72702)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoReplace send_ft_action() driver_op with send_action()
Jouni Malinen [Sat, 6 Dec 2014 16:13:29 +0000 (18:13 +0200)] 
Replace send_ft_action() driver_op with send_action()

This reduced number of unnecessarily duplicated driver interface
callback functions for sending Action frames by using the more generic
send_action() instead of FT specific send_ft_action().

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Move scanning related functionality to a separate file
Jouni Malinen [Sat, 6 Dec 2014 15:59:26 +0000 (17:59 +0200)] 
nl80211: Move scanning related functionality to a separate file

This helps in making the still overly large driver_nl80211.c somewhat
more manageable.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agohostapd: Fix memory leak on dynamic add-BSS error path
Jouni Malinen [Sat, 6 Dec 2014 15:42:23 +0000 (17:42 +0200)] 
hostapd: Fix memory leak on dynamic add-BSS error path

If "ADD bss_config=" command failed in driver_init() or
hostapd_setup_interface(), some of the allocated resources were not
freed properly.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Clean up nl80211_scan_common() to use nl80211_cmd_msg()
Jouni Malinen [Sat, 6 Dec 2014 14:47:12 +0000 (16:47 +0200)] 
nl80211: Clean up nl80211_scan_common() to use nl80211_cmd_msg()

This helper function had not used the nl80211_set_iface_id() helper, but
there is no reason why it couldn't re-use the same helper as other
places using nl80211_cmd_msg().

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Use nl80211_iface_msg() helper
Jouni Malinen [Sat, 6 Dec 2014 14:37:52 +0000 (16:37 +0200)] 
nl80211: Use nl80211_iface_msg() helper

Use the helper function to replace places that use nlmsg_alloc(),
nl80211_cmd(), and ifindex.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Use nl80211_bss_msg() helper
Jouni Malinen [Sat, 6 Dec 2014 14:27:26 +0000 (16:27 +0200)] 
nl80211: Use nl80211_bss_msg() helper

Use the helper function to replace places that use nlmsg_alloc(),
nl80211_cmd(), and either bss->ifindex or if_nametoindex(bss->ifname).

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Use nl80211_cmd_msg() for P2P Device operations
Jouni Malinen [Sat, 6 Dec 2014 14:09:39 +0000 (16:09 +0200)] 
nl80211: Use nl80211_cmd_msg() for P2P Device operations

bss->wdev_id_set is set for the non-detdev P2P Device, so
nl80211_cmd_msg() can be used as-is for these cases as well.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Use nl80211_drv_msg() helper
Jouni Malinen [Sat, 6 Dec 2014 14:05:54 +0000 (16:05 +0200)] 
nl80211: Use nl80211_drv_msg() helper

Use the helper function to replace places that use nlmsg_alloc(),
nl80211_cmd(), and drv->ifindex.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Move nl80211_set_iface_id() next its only remaining user
Jouni Malinen [Sat, 6 Dec 2014 13:17:30 +0000 (15:17 +0200)] 
nl80211: Move nl80211_set_iface_id() next its only remaining user

This function was in a bit strange location between struct family_data
and family_handler() definitions.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Use the new nl80211_cmd_msg() helper
Jouni Malinen [Sat, 6 Dec 2014 11:04:29 +0000 (13:04 +0200)] 
nl80211: Use the new nl80211_cmd_msg() helper

This removes duplicated code for building nl80211 commands for a BSS.
This commit handles the functions that were already using
nl80211_set_iface_id().

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Add nl80211_*_msg() helpers
Jouni Malinen [Sat, 6 Dec 2014 10:56:05 +0000 (12:56 +0200)] 
nl80211: Add nl80211_*_msg() helpers

These new functions can be used to both allocate and build a header for
most nl80211 commands.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Continue getting rid of NLA_PUT* macro use
Jouni Malinen [Fri, 5 Dec 2014 18:33:08 +0000 (20:33 +0200)] 
nl80211: Continue getting rid of NLA_PUT* macro use

This gets rid of more NLA_PUT* macro uses in nl80211 to reduce the
number of functions that depend on the hidden behavior of jumping to the
nla_put_failure label.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agonl80211: Get rid of NLA_PUT* macro use in capability checking
Jouni Malinen [Fri, 5 Dec 2014 17:24:38 +0000 (19:24 +0200)] 
nl80211: Get rid of NLA_PUT* macro use in capability checking

This gets rid of NLA_PUT* macro use in checking nl80211 capabilities to
reduce the number of functions that depend on the hidden behavior of
jumping to the nla_put_failure label.

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoPCSC: Make AID copying easier for static analyzers
Jouni Malinen [Fri, 5 Dec 2014 21:18:56 +0000 (23:18 +0200)] 
PCSC: Make AID copying easier for static analyzers

Use a separate pointer and length field instead of trying to copy from a
struct field that has only part of the full buffer available.
(CID 68115)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoMake GTK length validation easier to analyze
Jouni Malinen [Fri, 5 Dec 2014 21:05:11 +0000 (23:05 +0200)] 
Make GTK length validation easier to analyze

Bounds checking for gd->gtk_len in wpa_supplicant_check_group_cipher()
was apparently too complex for some static analyzers. Use a local
variable and a more explicit validation step to avoid false report.
(CID 62864)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoFT: Make aes_wrap() call easier to analyze
Jouni Malinen [Fri, 5 Dec 2014 20:59:20 +0000 (22:59 +0200)] 
FT: Make aes_wrap() call easier to analyze

Using aes_wrap() to initialize a data structure seemed to be too much
for some static analyzers to understand. Make it obvious that the target
is not just the single struct member. (CID 68111)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoFT: Make aes_unwrap() calls easier to analyze
Jouni Malinen [Fri, 5 Dec 2014 20:52:06 +0000 (22:52 +0200)] 
FT: Make aes_unwrap() calls easier to analyze

Using aes_unwrap() to initialize a data structure seemed to be too much
for some static analyzers to understand. Make it obvious that the target
is initialized and that the target is not just the single struct member.
In addition, clean up the design to avoid removal of const with a
typecast. (CID 68112, CID 68134, CID 68135, CID 68136)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agoP2P: Split p2p_channels_union() into two functions
Jouni Malinen [Fri, 5 Dec 2014 20:34:27 +0000 (22:34 +0200)] 
P2P: Split p2p_channels_union() into two functions

The separate p2p_channels_union_inplace() makes the function easier for
static analyzers to see that the result buffer is always initialized.
(CID 74494)

Signed-off-by: Jouni Malinen <j@w1.fi>
10 years agotests: Optimize FT test cases
Jouni Malinen [Fri, 5 Dec 2014 15:12:30 +0000 (17:12 +0200)] 
tests: Optimize FT test cases

Use single channel scan instead of full scan to save time. In addition,
use EAP-GPSK which takes significantly less CPU that EAP-EKE with
default parameters.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: FT_DS with unknown target
Jouni Malinen [Fri, 5 Dec 2014 15:05:46 +0000 (17:05 +0200)] 
tests: FT_DS with unknown target

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: TDLS teardown using wildcard address
Jouni Malinen [Fri, 5 Dec 2014 14:56:14 +0000 (16:56 +0200)] 
tests: TDLS teardown using wildcard address

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: Disabling WNM keep-alive and hostapd doing client poll
Jouni Malinen [Fri, 5 Dec 2014 14:51:21 +0000 (16:51 +0200)] 
tests: Disabling WNM keep-alive and hostapd doing client poll

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: wpa_supplicant ctrl_iface SET operations
Jouni Malinen [Fri, 5 Dec 2014 14:24:21 +0000 (16:24 +0200)] 
tests: wpa_supplicant ctrl_iface SET operations

This adds more test coverage for wpa_supplicant SET ctrl_iface command.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: SET disallow_aps in P2P GO mode
Jouni Malinen [Fri, 5 Dec 2014 14:21:10 +0000 (16:21 +0200)] 
tests: SET disallow_aps in P2P GO mode

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: Optimize WFD connect_cli() calls
Jouni Malinen [Fri, 5 Dec 2014 13:30:46 +0000 (15:30 +0200)] 
tests: Optimize WFD connect_cli() calls

There is no need to run full scan in these test cases, so use single
channel scan to save time.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agotests: WFD_SUBELEM_SET/GET with all parameter
Jouni Malinen [Fri, 5 Dec 2014 13:24:08 +0000 (15:24 +0200)] 
tests: WFD_SUBELEM_SET/GET with all parameter

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years agoWFD: Allow WFD_SUBELEM_SET/GET all to be used with full IE buffer
Jouni Malinen [Fri, 5 Dec 2014 13:22:33 +0000 (15:22 +0200)] 
WFD: Allow WFD_SUBELEM_SET/GET all to be used with full IE buffer

This extends the previously used WFD_SUBELEM_SET/GET <subelem id> design
to allow special "all" value to be used as an id to indicate that all
WFD subelements are to be set/get. This uses similar interface as was
previously added over D-Bus.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>