fix buffer overrun and uninitialized variable
This commit is contained in:
parent
efe2bf1ba5
commit
efeeb73ef5
3 changed files with 11 additions and 8 deletions
|
|
@ -107,6 +107,9 @@ void *msh_allocate(SIZE_TYPE size) {
|
||||||
};
|
};
|
||||||
|
|
||||||
void msh_deallocate(void *ptr) {
|
void msh_deallocate(void *ptr) {
|
||||||
|
if (ptr == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
msh_linux_block *block = get_metadata_block(ptr);
|
msh_linux_block *block = get_metadata_block(ptr);
|
||||||
block->free = 1;
|
block->free = 1;
|
||||||
if (block->prev && block->prev->free) {
|
if (block->prev && block->prev->free) {
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ msh_linux_env_item *env_items = 0;
|
||||||
msh_linux_env_item *env_item_tail = 0;
|
msh_linux_env_item *env_item_tail = 0;
|
||||||
|
|
||||||
void msh_linux_env_map_init() {
|
void msh_linux_env_map_init() {
|
||||||
msh_file *env_file;
|
msh_file *env_file = 0;
|
||||||
SIZE_TYPE cur;
|
SIZE_TYPE cur = 0;
|
||||||
char *file_buf;
|
char *file_buf = 0;
|
||||||
char ch = 1;
|
char ch = 1;
|
||||||
int counter = 0, i = 0;
|
int counter = 0, i = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ int msh_execute(char *cmd, char **args) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SIZE_TYPE fork = (SIZE_TYPE)SYSCALL(fork, 0);
|
SIZE_TYPE fork = (SIZE_TYPE)SYSCALL(fork, 0);
|
||||||
// int fork = 0;
|
|
||||||
|
|
||||||
if (fork == 0) {
|
if (fork == 0) {
|
||||||
char **env_translated = 0;
|
char **env_translated = 0;
|
||||||
|
|
@ -52,7 +51,8 @@ int msh_execute(char *cmd, char **args) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
char *entry =
|
char *entry =
|
||||||
msh_allocate(item_list->key_len + item_list->value_len + 2);
|
msh_allocate(item_list->key_len + item_list->value_len + 2);
|
||||||
msh_str_copy_strs(entry, item_list->key, "=", item_list->value, "\0");
|
msh_str_copy_strs(entry, item_list->key, "=", item_list->value, "\0",
|
||||||
|
0);
|
||||||
env_translated[i++] = entry;
|
env_translated[i++] = entry;
|
||||||
}
|
}
|
||||||
item_list = item_list->next;
|
item_list = item_list->next;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue