aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2013-06-19 12:39:12 +0200
committerTobias Brunner <tobias@strongswan.org>2013-07-08 18:49:30 +0200
commitd27f225d9a1064b5883002a293d6adddfbc99a07 (patch)
tree1350ed1a7ccf44fdcfefac02e204406eaddb0b69
parentf460facdca9995e32d1c69f84945a306c6063a40 (diff)
downloadstrongswan-d27f225d9a1064b5883002a293d6adddfbc99a07.tar.bz2
strongswan-d27f225d9a1064b5883002a293d6adddfbc99a07.tar.xz
Use strpfx() helper where appropriate
-rw-r--r--src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c14
-rw-r--r--src/libcharon/plugins/load_tester/load_tester_config.c2
-rw-r--r--src/libcharon/plugins/stroke/stroke_config.c10
-rw-r--r--src/libcharon/plugins/stroke/stroke_cred.c13
-rw-r--r--src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c4
-rw-r--r--src/libhydra/plugins/resolve/resolve_handler.c2
-rw-r--r--src/libimcv/os_info/os_info.c4
-rw-r--r--src/libstrongswan/plugins/ldap/ldap_fetcher.c2
-rw-r--r--src/libstrongswan/plugins/mysql/mysql_database.c2
-rw-r--r--src/libstrongswan/plugins/sqlite/sqlite_database.c2
-rw-r--r--src/libstrongswan/plugins/sshkey/sshkey_builder.c2
11 files changed, 28 insertions, 29 deletions
diff --git a/src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c b/src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c
index 96f437583..49e3dd142 100644
--- a/src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c
+++ b/src/libcharon/plugins/eap_mschapv2/eap_mschapv2.c
@@ -782,7 +782,7 @@ static status_t process_peer_success(private_eap_mschapv2_t *this,
enumerator = enumerator_create_token(message, " ", " ");
while (enumerator->enumerate(enumerator, &token))
{
- if (strneq(token, "S=", 2))
+ if (strpfx(token, "S="))
{
chunk_t hex;
token += 2;
@@ -795,7 +795,7 @@ static status_t process_peer_success(private_eap_mschapv2_t *this,
hex = chunk_create(token, AUTH_RESPONSE_LEN - 2);
auth_string = chunk_from_hex(hex, NULL);
}
- else if (strneq(token, "M=", 2))
+ else if (strpfx(token, "M="))
{
token += 2;
msg = strdup(token);
@@ -864,16 +864,16 @@ static status_t process_peer_failure(private_eap_mschapv2_t *this,
enumerator = enumerator_create_token(message, " ", " ");
while (enumerator->enumerate(enumerator, &token))
{
- if (strneq(token, "E=", 2))
+ if (strpfx(token, "E="))
{
token += 2;
error = atoi(token);
}
- else if (strneq(token, "R=", 2))
+ else if (strpfx(token, "R="))
{
/* ignore retriable */
}
- else if (strneq(token, "C=", 2))
+ else if (strpfx(token, "C="))
{
chunk_t hex;
token += 2;
@@ -886,11 +886,11 @@ static status_t process_peer_failure(private_eap_mschapv2_t *this,
hex = chunk_create(token, 2 * CHALLENGE_LEN);
challenge = chunk_from_hex(hex, NULL);
}
- else if (strneq(token, "V=", 2))
+ else if (strpfx(token, "V="))
{
/* ignore version */
}
- else if (strneq(token, "M=", 2))
+ else if (strpfx(token, "M="))
{
token += 2;
msg = strdup(token);
diff --git a/src/libcharon/plugins/load_tester/load_tester_config.c b/src/libcharon/plugins/load_tester/load_tester_config.c
index a64affde8..ebadf44ca 100644
--- a/src/libcharon/plugins/load_tester/load_tester_config.c
+++ b/src/libcharon/plugins/load_tester/load_tester_config.c
@@ -355,7 +355,7 @@ static void generate_auth_cfg(private_load_tester_config_t *this, char *str,
}
}
}
- else if (strneq(str, "eap", strlen("eap")))
+ else if (strpfx(str, "eap"))
{ /* EAP authentication, use a NAI */
class = AUTH_CLASS_EAP;
if (*(str + strlen("eap")) == '-')
diff --git a/src/libcharon/plugins/stroke/stroke_config.c b/src/libcharon/plugins/stroke/stroke_config.c
index da8d35c40..079e65f11 100644
--- a/src/libcharon/plugins/stroke/stroke_config.c
+++ b/src/libcharon/plugins/stroke/stroke_config.c
@@ -559,9 +559,9 @@ static auth_cfg_t *build_auth_cfg(private_stroke_config_t *this,
}
/* authentication metod (class, actually) */
- if (strneq(auth, "pubkey", strlen("pubkey")) ||
- strneq(auth, "rsa", strlen("rsa")) ||
- strneq(auth, "ecdsa", strlen("ecdsa")))
+ if (strpfx(auth, "pubkey") ||
+ strpfx(auth, "rsa") ||
+ strpfx(auth, "ecdsa"))
{
cfg->add(cfg, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_PUBKEY);
build_crl_policy(cfg, local, msg->add_conn.crl_policy);
@@ -572,7 +572,7 @@ static auth_cfg_t *build_auth_cfg(private_stroke_config_t *this,
{
cfg->add(cfg, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_PSK);
}
- else if (strneq(auth, "xauth", 5))
+ else if (strpfx(auth, "xauth"))
{
char *pos;
@@ -588,7 +588,7 @@ static auth_cfg_t *build_auth_cfg(private_stroke_config_t *this,
identification_create_from_string(msg->add_conn.xauth_identity));
}
}
- else if (strneq(auth, "eap", 3))
+ else if (strpfx(auth, "eap"))
{
eap_vendor_type_t *type;
diff --git a/src/libcharon/plugins/stroke/stroke_cred.c b/src/libcharon/plugins/stroke/stroke_cred.c
index 6b37ac787..474417886 100644
--- a/src/libcharon/plugins/stroke/stroke_cred.c
+++ b/src/libcharon/plugins/stroke/stroke_cred.c
@@ -175,7 +175,7 @@ METHOD(stroke_cred_t, load_ca, certificate_t*,
certificate_t *cert = NULL;
char path[PATH_MAX];
- if (strneq(filename, "%smartcard", strlen("%smartcard")))
+ if (strpfx(filename, "%smartcard"))
{
smartcard_format_t format;
char module[SC_PART_LEN], keyid[SC_PART_LEN];
@@ -239,7 +239,7 @@ METHOD(stroke_cred_t, load_peer, certificate_t*,
certificate_t *cert = NULL;
char path[PATH_MAX];
- if (strneq(filename, "%smartcard", strlen("%smartcard")))
+ if (strpfx(filename, "%smartcard"))
{
smartcard_format_t format;
char module[SC_PART_LEN], keyid[SC_PART_LEN];
@@ -787,7 +787,7 @@ static bool load_pin(mem_cred_t *secrets, chunk_t line, int line_nr,
}
chunk = chunk_from_hex(chunk_create(keyid, strlen(keyid)), NULL);
- if (secret.len == 7 && strneq(secret.ptr, "%prompt", 7))
+ if (secret.len == 7 && strpfx(secret.ptr, "%prompt"))
{
free(secret.ptr);
if (!prompt)
@@ -880,7 +880,7 @@ static bool load_from_file(chunk_t line, int line_nr, FILE *prompt,
return FALSE;
}
}
- if (secret.len == 7 && strneq(secret.ptr, "%prompt", 7))
+ if (secret.len == 7 && strpfx(secret.ptr, "%prompt"))
{
callback_cred_t *cb;
passphrase_cb_data_t pp_data = {
@@ -1142,8 +1142,7 @@ static void load_secrets(private_stroke_cred_t *this, mem_cred_t *secrets,
{
continue;
}
- if (line.len > strlen("include ") &&
- strneq(line.ptr, "include ", strlen("include ")))
+ if (line.len > strlen("include ") && strpfx(line.ptr, "include "))
{
char **expanded, *dir, pattern[PATH_MAX];
u_char *pos;
@@ -1211,7 +1210,7 @@ static void load_secrets(private_stroke_cred_t *this, mem_cred_t *secrets,
continue;
}
- if (line.len > 2 && strneq(": ", line.ptr, 2))
+ if (line.len > 2 && strpfx(line.ptr, ": "))
{
/* no ids, skip the ':' */
ids = chunk_empty;
diff --git a/src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c b/src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c
index 5ca5879ff..38c92ce71 100644
--- a/src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c
+++ b/src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c
@@ -78,7 +78,7 @@
/** this is the default number of ipsec devices */
#define DEFAULT_IPSEC_DEV_COUNT 4
/** TRUE if the given name matches an ipsec device */
-#define IS_IPSEC_DEV(name) (strneq((name), IPSEC_DEV_PREFIX, sizeof(IPSEC_DEV_PREFIX) - 1))
+#define IS_IPSEC_DEV(name) (strpfx((name), IPSEC_DEV_PREFIX))
/** the following stuff is from ipsec_tunnel.h */
struct ipsectunnelconf
@@ -2332,7 +2332,7 @@ METHOD(kernel_ipsec_t, query_policy, status_t,
while (fgets(line, sizeof(line), file))
{
- if (strneq(line, said, strlen(said)))
+ if (strpfx(line, said))
{
/* fine we found the correct line, now find the idle time */
u_int32_t idle_time;
diff --git a/src/libhydra/plugins/resolve/resolve_handler.c b/src/libhydra/plugins/resolve/resolve_handler.c
index 6b8d6be7f..6c57fa0bf 100644
--- a/src/libhydra/plugins/resolve/resolve_handler.c
+++ b/src/libhydra/plugins/resolve/resolve_handler.c
@@ -126,7 +126,7 @@ static void remove_nameserver(private_resolve_handler_t *this,
/* copy all, but matching line */
while (fgets(line, sizeof(line), in))
{
- if (strneq(line, matcher, strlen(matcher)))
+ if (strpfx(line, matcher))
{
DBG1(DBG_IKE, "removing DNS server %H from %s",
addr, this->file);
diff --git a/src/libimcv/os_info/os_info.c b/src/libimcv/os_info/os_info.c
index 2c49cb01d..17000cd27 100644
--- a/src/libimcv/os_info/os_info.c
+++ b/src/libimcv/os_info/os_info.c
@@ -182,8 +182,8 @@ METHOD(os_info_t, get_setting, chunk_t,
size_t i = 0;
chunk_t value;
- if (!strneq(name, "/etc/", 5) && !strneq(name, "/proc/", 6) &&
- !strneq(name, "/sys/", 5) && !strneq(name, "/var/", 5))
+ if (!strpfx(name, "/etc/") && !strpfx(name, "/proc/") &&
+ !strpfx(name, "/sys/") && !strpfx(name, "/var/"))
{
/**
* In order to guarantee privacy, only settings from the
diff --git a/src/libstrongswan/plugins/ldap/ldap_fetcher.c b/src/libstrongswan/plugins/ldap/ldap_fetcher.c
index 40b6d1f63..fe4c55545 100644
--- a/src/libstrongswan/plugins/ldap/ldap_fetcher.c
+++ b/src/libstrongswan/plugins/ldap/ldap_fetcher.c
@@ -112,7 +112,7 @@ METHOD(fetcher_t, fetch, status_t,
status_t status = FAILED;
chunk_t *result = userdata;
- if (!strneq(url, "ldap", 4))
+ if (!strpfx(url, "ldap"))
{
return NOT_SUPPORTED;
}
diff --git a/src/libstrongswan/plugins/mysql/mysql_database.c b/src/libstrongswan/plugins/mysql/mysql_database.c
index 789f12f20..8bd64692c 100644
--- a/src/libstrongswan/plugins/mysql/mysql_database.c
+++ b/src/libstrongswan/plugins/mysql/mysql_database.c
@@ -666,7 +666,7 @@ mysql_database_t *mysql_database_create(char *uri)
conn_t *conn;
private_mysql_database_t *this;
- if (!strneq(uri, "mysql://", 8))
+ if (!strpfx(uri, "mysql://"))
{
return NULL;
}
diff --git a/src/libstrongswan/plugins/sqlite/sqlite_database.c b/src/libstrongswan/plugins/sqlite/sqlite_database.c
index 1fb306579..41d45dee7 100644
--- a/src/libstrongswan/plugins/sqlite/sqlite_database.c
+++ b/src/libstrongswan/plugins/sqlite/sqlite_database.c
@@ -319,7 +319,7 @@ sqlite_database_t *sqlite_database_create(char *uri)
/**
* parse sqlite:///path/to/file.db uri
*/
- if (!strneq(uri, "sqlite://", 9))
+ if (!strpfx(uri, "sqlite://"))
{
return NULL;
}
diff --git a/src/libstrongswan/plugins/sshkey/sshkey_builder.c b/src/libstrongswan/plugins/sshkey/sshkey_builder.c
index 986e860d9..d6a7c645a 100644
--- a/src/libstrongswan/plugins/sshkey/sshkey_builder.c
+++ b/src/libstrongswan/plugins/sshkey/sshkey_builder.c
@@ -85,7 +85,7 @@ static sshkey_public_key_t *parse_public_key(chunk_t blob)
BUILD_RSA_MODULUS, n, BUILD_RSA_PUB_EXP, e, BUILD_END);
}
else if (format.len > strlen(ECDSA_PREFIX) &&
- strneq(format.ptr, ECDSA_PREFIX, strlen(ECDSA_PREFIX)))
+ strpfx(format.ptr, ECDSA_PREFIX))
{
chunk_t ec_blob, identifier, q, oid, encoded;
sshkey_public_key_t *key;