Skip to content

Commit

Permalink
Correct autorun handling when clink's entry is first.
Browse files Browse the repository at this point in the history
  • Loading branch information
mridgers committed Feb 4, 2013
1 parent d58d7b6 commit 2caa439
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions clink/loader/autorun.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ static int find_clink_entry(const char* value, int* left, int* right)
return 1;
}

//------------------------------------------------------------------------------
static const char* get_cmd_start(const char* cmd)
{
while (isspace(*cmd) || *cmd == '&')
{
++cmd;
}

return cmd;
}

//------------------------------------------------------------------------------
static int uninstall_autorun(const char* clink_path, int wow64)
{
Expand All @@ -202,7 +213,7 @@ static int uninstall_autorun(const char* clink_path, int wow64)
ret = 1;
if (key_value && find_clink_entry(key_value, &left, &right))
{
char* read;
const char* read;
char* write;
int i, n;

Expand All @@ -218,15 +229,16 @@ static int uninstall_autorun(const char* clink_path, int wow64)
++read;
}

if (*key_value == '\0')
read = get_cmd_start(key_value);
if (*read == '\0')
{
// Empty key. We might as well delete it.
if (!delete_value(cmd_proc_key, "AutoRun"))
{
ret = 0;
}
}
else if (!set_value(cmd_proc_key, "AutoRun", key_value))
else if (!set_value(cmd_proc_key, "AutoRun", read))
{
ret = 0;
}
Expand All @@ -245,6 +257,7 @@ static int uninstall_autorun(const char* clink_path, int wow64)
static int install_autorun(const char* clink_path, int wow64)
{
HKEY cmd_proc_key;
const char* value;
char* new_value;
char* key_value;
int i;
Expand Down Expand Up @@ -286,8 +299,9 @@ static int install_autorun(const char* clink_path, int wow64)
}

// Set it
value = get_cmd_start(new_value);
i = 1;
if (!set_value(cmd_proc_key, "AutoRun", new_value))
if (!set_value(cmd_proc_key, "AutoRun", value))
{
i = 0;
}
Expand Down

0 comments on commit 2caa439

Please sign in to comment.