summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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;
}