Lines 758-773
execve(const char *filename, char *const
Link Here
|
758 |
new_envp = strndupa(old_envp, max_envp_len - 1); |
758 |
new_envp = strndupa(old_envp, max_envp_len - 1); |
759 |
|
759 |
|
760 |
/* LD_PRELOAD already have variables other than sandbox_lib, |
760 |
/* LD_PRELOAD already have variables other than sandbox_lib, |
761 |
* thus we have to add sandbox_lib via a white space. */ |
761 |
* thus we have to add sandbox_lib seperated via a whitespace. */ |
762 |
if (0 != strcmp(envp[count], "LD_PRELOAD=")) { |
762 |
if (0 != strncmp(envp[count], "LD_PRELOAD=", max_envp_len - 1)) { |
763 |
strncpy(new_envp + strlen(old_envp), ":", |
763 |
strncat(new_envp, " ", max_envp_len - strlen(new_envp)); |
764 |
max_envp_len - strlen(new_envp)); |
764 |
strncat(new_envp, sandbox_lib, max_envp_len - strlen(new_envp)); |
765 |
strncpy(new_envp + strlen(old_envp) + 1, sandbox_lib, |
|
|
766 |
max_envp_len - strlen(new_envp)); |
767 |
} else { |
765 |
} else { |
768 |
strncpy(new_envp + |
766 |
strncat(new_envp, sandbox_lib, max_envp_len - strlen(new_envp)); |
769 |
strlen(old_envp), sandbox_lib, |
|
|
770 |
max_envp_len - strlen(new_envp)); |
771 |
} |
767 |
} |
772 |
|
768 |
|
773 |
/* Valid string? */ |
769 |
/* Valid string? */ |
Lines 776-782
execve(const char *filename, char *const
Link Here
|
776 |
/* envp[count] = new_envp; |
772 |
/* envp[count] = new_envp; |
777 |
* |
773 |
* |
778 |
* Get rid of the "read-only" warnings */ |
774 |
* Get rid of the "read-only" warnings */ |
779 |
memcpy((void *) &envp[count], &new_envp, sizeof (new_envp)); |
775 |
memcpy((char *) &envp[count], (char *) &new_envp, sizeof (char *)); |
780 |
|
776 |
|
781 |
break; |
777 |
break; |
782 |
} |
778 |
} |
Lines 793-799
execve(const char *filename, char *const
Link Here
|
793 |
/* Restore envp[count] again. |
789 |
/* Restore envp[count] again. |
794 |
* |
790 |
* |
795 |
* envp[count] = old_envp; */ |
791 |
* envp[count] = old_envp; */ |
796 |
memcpy((void *) &envp[count], &old_envp, sizeof (old_envp)); |
792 |
memcpy((char *) &envp[count], (char *) &old_envp, sizeof (char *)); |
797 |
old_envp = NULL; |
793 |
old_envp = NULL; |
798 |
} |
794 |
} |
799 |
} |
795 |
} |