path: root/src/utils
Commit message (Collapse)AuthorAgeFilesLines
* Removed redundant NULL check for b in wpabuf_concat()Nishant Chaprana2016-10-281-4/+2
| | | | Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
* Move CRC-32 routine from wlantest to src/utilsJouni Malinen2016-10-093-0/+100
| | | | | | | This allows the CRC-32 routine to be shared for other purposes in addition to the WEP/TKIP/FCS within wlantest. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* Fix spelling mistakes in number of commentsNishant Chaprana2016-09-301-1/+1
| | | | Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
* utils: os_unix: Use access() for checking file existenceRahul Bedarkar2016-08-071-5/+1
| | | | | | | Trying to open file for checking file existence seems to be too much. Instead use access system call which is meant for the same. Signed-off-by: Rahul Bedarkar <rahulbedarkar89@gmail.com>
* Link to, and adjust types for, the PCSC framework included with OSXArran Cudbard-Bell2016-08-071-2/+19
| | | | Signed-off-by: Arran Cudbard-Bell <a.cudbardb@freeradius.org>
* Share a single str_starts() implementationJouni Malinen2016-08-062-0/+8
| | | | | | No need to define this as a static function in multiple files. Signed-off-by: Jouni Malinen <j@w1.fi>
* Move extern declarations for ext_password backends into a header fileJouni Malinen2016-06-242-4/+6
| | | | | | | | This gets rid of a sparse warning and also allows the compatibility of the declarations to be verified (a missing const declaration is fixed here as well). Signed-off-by: Jouni Malinen <j@w1.fi>
* tests: Declare module test functions in a header fileJouni Malinen2016-06-232-0/+21
| | | | | | This gets rid of number of warnings from sparse. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* radiotap: Silence sparse warnings about byte order swappingJouni Malinen2016-06-234-6/+6
| | | | | | | These little endian fields were not marked properly and the type case in the get_unaligned_* helper macros were causing warnings from sparse. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* trace: Define externs in a header fileJouni Malinen2016-06-231-0/+4
| | | | | | This gets rid of some unnecessary strace warnings from test builds. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* Undefine __bitwise before defining it for sparseJouni Malinen2016-06-231-0/+1
| | | | | | | This gets rid of a compiler warning due to a bit different construction in linux/types.h. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* curl: Don't free memory for subjectAltName before calling callbackCedric Izoard2016-06-191-3/+1
| | | | | | | | Freeing memory for subjectAltName in parse_cert(), will give cert_cb pointers to freed memory zone that may already been overwritten. Memory for subjectAltName is released in parse_cert_free(). Signed-off-by: Cedric Izoard <cedric.izoard@ceva-dsp.com>
* wpa_cli: Add backspace key process for some terminalSiWon Kang2016-05-131-0/+6
| | | | | | | | | | In some terminal, verified with gtkterm and teraterm, backspace key is not properly processed. For instance, type 'abc', 3 times of backspace key press then '123' shows the result of 'abc123' instead of '123'. To fix this, add a routine to process '\b' character input when using edit_simple.c instead of edit.c (i.e., without CONFIG_WPA_CLI_EDIT=y). Signed-off-by: Siwon Kang <kkangshawn@gmail.com>
* Remove newlines from wpa_supplicant config network outputPaul Stewart2016-05-022-0/+12
| | | | | | | | | | Spurious newlines output while writing the config file can corrupt the wpa_supplicant configuration. Avoid writing these for the network block parameters. This is a generic filter that cover cases that may not have been explicitly addressed with a more specific commit to avoid control characters in the psk parameter. Signed-off-by: Paul Stewart <pstew@google.com>
* WPS: Reject a Credential with invalid passphraseJouni Malinen2016-05-022-0/+13
| | | | | | | | | | | | | | | WPA/WPA2-Personal passphrase is not allowed to include control characters. Reject a Credential received from a WPS Registrar both as STA (Credential) and AP (AP Settings) if the credential is for WPAPSK or WPA2PSK authentication type and includes an invalid passphrase. This fixes an issue where hostapd or wpa_supplicant could have updated the configuration file PSK/passphrase parameter with arbitrary data from an external device (Registrar) that may not be fully trusted. Should such data include a newline character, the resulting configuration file could become invalid and fail to be parsed. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* utils: Add ssid_parse() functionDavid Spinadel2016-04-162-0/+56
| | | | | | | | | | Add a function that parses SSID in text or hex format. In case of the text format, the SSID is enclosed in double quotes. In case of the hex format, the SSID must include only hex digits and not be enclosed in double quotes. The input string may include other arguments after the SSID. Signed-off-by: David Spinadel <david.spinadel@intel.com>
* utils: Rename hostapd_parse_bin to wpabuf_parse_bin and move itDavid Spinadel2016-04-092-0/+31
| | | | | | | Make the function available as part of the wpabuf API. Use this renamed function where possible. Signed-off-by: David Spinadel <david.spinadel@intel.com>
* wlantest: Use local ETH_P_IP define instead of linux/if_ether.hJouni Malinen2016-03-261-0/+3
| | | | | | | | There is no strong need for pulling in linux/if_ether.h here since all that is needed if ETH_P_IP and we already cover multiple other ETH_P_* values in utils/common.h. Signed-off-by: Jouni Malinen <j@w1.fi>
* libxml2: Check for xmlDocDumpFormatMemory() error caseJouni Malinen2016-03-161-0/+2
| | | | | | | | Since this function needs to allocate memory, it might fail. Check that the returned memory pointer is not NULL before trying to parse the output. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* Fix CONFIG_WPA_TRACE=y compilation without CONFIG_WPA_TRACE_BFD=yEliad Peller2016-03-031-0/+2
| | | | | | | | | | | | | | | | syms is defined only for WPA_TRACE_BFD: ../src/utils/trace.c: In function ‘wpa_trace_deinit’: ../src/utils/trace.c:372:7: error: ‘syms’ undeclared (first use in this function) free(syms); ^ ../src/utils/trace.c:372:7: note: each undeclared identifier is reported only once for each function it appears in make: *** [../src/utils/trace.o] Error 1 make: *** Waiting for unfinished jobs.... Add appropriate #ifdef. Signed-off-by: Eliad Peller <eliad@wizery.com>
* kqueue: Use 0 instead of NULL for udataRoy Marples2016-02-181-3/+3
| | | | | | | Use 0 for udata instead of NULL for portability. NetBSD uses uintptr_t, others a pointer. Signed-off-by: Roy Marples <roy@marples.name>
* ctype functions require an unsigned charRoy Marples2016-02-181-1/+1
| | | | | | | | Ensure that characters are represented as unsigned char when using isblank() and isspace(). These function take in a "int c" argument, but it needs to be unsigned for the cases where EOF is not indicated. Signed-off-by: Roy Marples <roy@marples.name>
* trace: Free symbols on program exitJouni Malinen2016-02-163-0/+10
| | | | | | | This makes valgrind memleak checks with CONFIG_WPA_TRACE=y somewhat cleaner. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* OpenSSL: Fix memory leak in OCSP parsingJouni Malinen2016-02-151-0/+2
| | | | | | The result from OCSP_cert_to_id() needs to be freed. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* curl: Fix memory leak in subjectAltName parsingJouni Malinen2016-02-151-1/+3
| | | | | | The parsed data from X509_get_ext_d2i() needs to be freed. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* eloop: Clean up coding style for eloop debug printsJouni Malinen2016-02-071-5/+5
| | | | Signed-off-by: Jouni Malinen <j@w1.fi>
* Implement kqueue(2) support via CONFIG_ELOOP_KQUEUERoy Marples2016-02-071-41/+237
| | | | | | | | | | | NOTE: kqueue has to be closed and re-build after forking. epoll *should* do the same, but it seems that wpa_supplicant doesn't need it at least. I have re-worked a little bit of the epoll code (moved into a similar kqueue function) so it's trivial to requeue epoll if needed in the future. Signed-off-by: Roy Marples <roy@marples.name>
* eloop: Add eloop_sock_requeue()Roy Marples2016-02-073-0/+20
| | | | | | | This function can be used to re-build eloop socket tables after forking for eloop implementations that need this. Signed-off-by: Roy Marples <roy@marples.name>
* wpa_supplicant: Fix couple of C++ compiler errors with header filesRoshan Pius2016-02-061-8/+8
| | | | | | | | | | | Need to include these headers in C++ files for adding a binder interface to wpa_supplicant. So, fix the following C++ compiler errors in them: 1. Add explicit C-style casts in wpa_buf.h header. 2. Move the nested definition of wpa_driver_scan_ssid in driver.h outside of wpa_driver_scan_params because it is used in another structure below. Signed-off-by: Roshan Pius <rpius@google.com>
* OSU: Add debug printing of more LogotypeExtn fieldsJouni Malinen2016-02-041-2/+14
| | | | | | | Couple of the image info fields were not printed previously in debug log. Add those to make this more complete. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* utils: Fix NULL pointer dereference with unexpected kernel behaviorAyala Beker2015-12-171-1/+1
| | | | | | | | Fix mostly theoretical NULL pointer dereference in wpa_debug_open_linux_tracing() if /proc/mounts were to return a malformed line. Signed-off-by: Ayala Beker <ayala.beker@intel.com>
* HTTP (curl): OCSP with BoringSSLJouni Malinen2015-12-041-0/+33
| | | | | | | | | This adds experimental support for using OCSP with libcurl that is built against BoringSSL. This needs small modifications to libcurl to allow CURLOPT_SSL_VERIFYSTATUS to be used to call SSL_enable_ocsp_stapling(connssl->handle) in ossl_connect_step1(). Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* Android: Give user the option for selecting browser for HS 2.0 OSUSomdas Bandyopadhyay2015-11-221-4/+2
| | | | | | | | | | | | When built with browser-android.c, hs20-osu-client used to always launch the native/stock Android browser for OSU user interaction. This browser is not present in all devices. It is better to give the option to the user to select his/her browser. Here the user will be shown a pop up to select the browser that he/she wants. Signed-off-by: Somdas Bandyopadhyay <somdas.bandyopadhyay@intel.com>
* Do not write ERROR level log entries if debug file is not usedJouni Malinen2015-10-251-10/+12
| | | | | | | | | | wpa_debug_reopen_file() used to write an error message at MSG_ERROR level if it was called with last_path == NULL (the last debug log file path not known). This is not a fatal error, but a normal case if wpa_debug_open_file() has not been used. Remove the error message and return success in such case. Signed-off-by: Jouni Malinen <j@w1.fi>
* PCSC: Avoid undefined behavior in pointer arithmeticJouni Malinen2015-10-251-4/+4
| | | | | | | | | Reorder terms in a way that no invalid pointers are generated with pos+len operations. end-pos is always defined (with a valid pos pointer) while pos+len could end up pointing beyond the end pointer which would be undefined behavior. Signed-off-by: Jouni Malinen <j@w1.fi>
* Portability fixes for FreeBSD - os_fdatasync()Rui Paulo2015-10-151-4/+4
| | | | | | Use fsync() when fdatasync() and F_FULLSYNC isn't available. Signed-off-by: Rui Paulo <rpaulo@freebsd.org>
* Escape DEL char (ASCII 127 decimal) in SSIDsJosh Lehan2015-10-141-1/+1
| | | | | | | | | While testing, I noticed that printf_encode() makes control characters human-readable, with one exemption, the DEL character (ASCII 127). Assuming this exemption was unintentional, make it appear as an escaped \x7f instead of a literal DEL character in the output. Signed-off-by: Josh Lehan <krellan@krellan.net>
* HTTP (curl): Fix compilation with BoringSSLJouni Malinen2015-10-091-0/+23
| | | | | | | Define the sk_*_{num,value}() macros in BoringSSL style if BoringSSL is used instead of OpenSSL. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* Portability fixes for OS XAlan T. DeKok2015-09-251-1/+36
| | | | | | Fix os_get_reltime() and os_fdatasync() for OS X. Signed-off-by: Alan DeKok <aland@freeradius.org>
* Make sure configuration is saved to storage deviceMitchell Wills2015-08-275-0/+45
| | | | | | | | | | | | Config file is written to a temp file and then it is renamed to the original config file. However, it is possible that the rename operation will be commited to storage while file data will be still in cache causing original config file to be empty or partially written in case of a system reboot without a clean shutdown. Make this less likely to occur by forcing the data to be written to the storage device before renaming the file. Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
* Android: Use more flexible userid when launching browser popupKanchanapally, Vidyullatha2015-08-131-2/+4
| | | | | | | | | | | It was possible for the Hotspot 2.0 case of OSU user interaction to fail with wpadebug browser due to permission denial in the "start" command ("java.lang.SecurityException: Permission Denial: startActivity asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL"). Avoid this by using more flexible USER_CURRENT_OR_SELF (-3) value with the --user argument. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* Move debug level string conversion functions to wpa_debug.cJouni Malinen2015-08-032-0/+42
| | | | | | | This makes it possible to use these helper functions from hostapd as well as the current use in wpa_supplicant. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* utils: Add cstr_token() functionMax Stepanov2015-07-262-17/+47
| | | | | | | | | | | Add an auxiliary cstr_token() function to get a token from a const char string. The function usage syntax is similar to str_token(), but unlike str_token() the function doesn't modify the buffer of the string. Change str_token() function implementation to use cstr_token(). Signed-off-by: Max Stepanov <Max.Stepanov@intel.com> Reviewed-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Reviewed-by: Ilan Peer <ilan.peer@intel.com>
* eloop: Fix cases where a socket is reopened from a timeout/signal handlerJouni Malinen2015-07-231-7/+22
| | | | | | | | | | | | | | | | | | | It was possible for a registered eloop socket handler to be unregistered and re-registered for a re-opened socket with the same fd from a timeout or signal handler. If such a case happened with the old socket having a pending event waiting for processing, some eloop combinations could end up calling the new handler function with the new socket and get stuck waiting for an event that has not yet happened on the new socket. This happened with timeout and signal handlers with all eloop.c types. In addition to that, the epoll case could also trigger this when a socket handler re-registered a re-opened socket. Fix these by checking whether there has been socket handler changes during processing and break the processing round by going back to select/poll/epoll for an updated result if any changes are done during the eloop handler calls before processing the old socket results. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* tests: eloop socket re-open from timeout/socket handlerJouni Malinen2015-07-231-0/+247
| | | | Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* eloop: Try to terminate more quickly on SIGINT and SIGTERMJouni Malinen2015-07-221-1/+15
| | | | | | | | | | | | | | | | | | | | It was possible for the SIGINT/SIGTERM signal to be received while processing a pending timeout/socket/signal event and then get stuck in the following select() call before processing the signal event. If no other events show up within the two second SIGALRM trigger, process will be terminated forcefully even though there would have been possibility to do clean termination assuming no operationg blocked for that two second time. Handle this more cleanly by checking for eloop.pending_terminate before starting the select()/poll()/epoll_wait() wait for the following event. Terminate the loop if pending signal handling requests termination. In addition, make eloop_terminated() return 1 on eloop.pending_terminate in addition to eloop.terminate since the process will be terminated shortly and there is no point in starting additional processing. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* tests: Additional module tests for src/utilsJouni Malinen2015-07-191-1/+178
| | | | Signed-off-by: Jouni Malinen <j@w1.fi>
* Drop CONFIG_TI_COMPILER ifdefsJouni Malinen2015-07-172-32/+0
| | | | | | | | This experimental support for Texas Instruments C compiler was never fully completed and it has not really been used in close to ten years, so drop this to simply the header files. Signed-off-by: Jouni Malinen <j@w1.fi>
* Add is_multicast_ether_addr()Anton Nayshtut2015-07-161-0/+5
| | | | | | | This helper function can be used to check whether a MAC address is a multicast (including broadcast) address. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
* hostapd: Global control interface notificationsAnton Nayshtut2015-07-162-0/+43
| | | | | | | | | | This commit implements hostapd global control interface notifications infrastructure. hostapd global control interface clients issue ATTACH/DETACH commands to register and deregister with hostapd correspondingly - the same way as for any other hostapd/wpa_supplicant control interface. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>