summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-09-10 18:18:18 +0000
committermidipix <writeonce@midipix.org>2017-09-10 23:08:13 -0400
commited1da24a11a6558dfa5b715e56e4273a0dfbc52e (patch)
treed03a2ceffeb539c8ad9b6e5e41f04f8f134ae045
parenta4031208e5dea11cbb0bbc95c402b57b662a94a1 (diff)
downloadntapi-ed1da24a11a6558dfa5b715e56e4273a0dfbc52e.tar.bz2
ntapi-ed1da24a11a6558dfa5b715e56e4273a0dfbc52e.tar.xz
envp primitives: re-implemented __ntapi_tt_get_env_var_meta_utf16().
-rw-r--r--src/argv/ntapi_tt_env_vars.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/src/argv/ntapi_tt_env_vars.c b/src/argv/ntapi_tt_env_vars.c
index 9b671b6..0d9553d 100644
--- a/src/argv/ntapi_tt_env_vars.c
+++ b/src/argv/ntapi_tt_env_vars.c
@@ -47,37 +47,31 @@ int32_t __stdcall __ntapi_tt_get_env_var_meta_utf16(
__in wchar16_t ** envp,
__out nt_env_var_meta_utf16 * env_var_meta)
{
- int idx;
+ wchar16_t ** penv;
wchar16_t * wch;
- #define EQUAL_SIGN 0x3D
-
- /* init */
- env_var_meta->name = 0;
- env_var_meta->value = 0;
- env_var_meta->envp_index = 0;
- env_var_meta->flags = 0;
-
/* lookup */
- for (idx=0; envp[idx] && !env_var_meta->value; idx++) {
- wch = envp[idx];
-
- while (*wch && (*wch != EQUAL_SIGN))
+ for (penv=envp; *penv; penv++) {
+ for (wch=penv[0]; *wch && (*wch != '='); )
wch++;
- if (*wch != EQUAL_SIGN)
- return NT_STATUS_ILLEGAL_CHARACTER;
+ if (*wch != '=')
+ return NT_STATUS_INVALID_USER_BUFFER;
- if (!(__ntapi->tt_strncmp_utf16(
- envp[idx],
+ if ((wch > *penv) && !(__ntapi->tt_strncmp_utf16(
+ *penv,
env_var_name,
- wch - envp[idx]))) {
- wch++;
- env_var_meta->name = envp[idx];
- env_var_meta->value = wch;
- env_var_meta->envp_index = idx;
+ wch - *penv))) {
+ /* match */
+ env_var_meta->name = *penv;
+ env_var_meta->value = ++wch;
+ env_var_meta->envp_index = penv - envp;
+ env_var_meta->flags = 0;
+
+
+ return NT_STATUS_SUCCESS;
}
}
- return NT_STATUS_SUCCESS;
+ return NT_STATUS_NOT_FOUND;
}