Skip to content

Commit

Permalink
Fix memory overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhch committed Sep 1, 2024
1 parent cf8f42d commit 28ea13b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@ macOS 13|lldb|NO

### History

- v1.6.1 2024-09-01
- v1.6.2 2024-09-01

Fix memory overflow

- v1.6.1 2024-09-01

Fix the array length to be empty

- v1.6 2024-09-01

Add built-in interpreter
Expand Down
20 changes: 10 additions & 10 deletions shellc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Function: Convert script into C code
* Author: ChenZhongChao
* Date: 2023-12-25
* Version: 1.6.1
* Version: 1.6.2
* Github: https://github.com/chenzhch/shellc.git
*/

Expand Down Expand Up @@ -560,9 +560,9 @@ static const char *first[] = {
" memset(summary, 0, sizeof(summary));",
" srand(getpid());",
" i = 0;",
" salt = strlen(command) + strlen(tracer) + strlen(digest);",
" seed = (char *) malloc((size_t) (salt + 1));",
" memset(seed, 0, salt + 1);",
" salt = strlen(command) + strlen(tracer) + strlen(digest) + 2;",
" seed = (char *) malloc((size_t) (salt + 16));",
" memset(seed, 0, salt + 16);",
" strcat(seed, command);",
" strcat(seed, tracer);",
" if (inner || anti) {",
Expand Down Expand Up @@ -1420,14 +1420,14 @@ int main(int argc, char **argv)
}
text = (char *) malloc(size);
if (inner_flag) {
salt = strlen(interpreter) + strlen(tracer) + strlen(digest);
seed = (char *) malloc(salt + 1);
memset(seed, 0, (size_t) (salt + 1));
salt = strlen(interpreter) + strlen(tracer) + strlen(digest) + 2;
seed = (char *) malloc(salt + 16);
memset(seed, 0, (size_t) (salt + 16));
strcat(seed, interpreter);
} else {
salt = strlen(command) + strlen(tracer) + strlen(digest);
seed = (char *) malloc(salt + 1);
memset(seed, 0, (size_t) (salt + 1));
salt = strlen(command) + strlen(tracer) + strlen(digest) + 2;
seed = (char *) malloc(salt + 16);
memset(seed, 0, (size_t) (salt + 16));
strcat(seed, command);
}
strcat(seed, tracer);
Expand Down
6 changes: 5 additions & 1 deletion 说明.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,14 @@ macOS 13|lldb|不支持


### 修改记录
- v1.6.1 2024-09-01
- v1.6.2 2024-09-01

修复内存溢出

- v1.6.1 2024-09-01

修复数组长度为空

- v1.6 2024-09-01

增加内置解释器功能
Expand Down

0 comments on commit 28ea13b

Please sign in to comment.