aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell/ash.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 853fafcc1..8e80a5228 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -360,12 +360,12 @@ struct forkshell {
360 /* struct parsefile *g_parsefile; */ 360 /* struct parsefile *g_parsefile; */
361 HANDLE hMapFile; 361 HANDLE hMapFile;
362 char *old_base; 362 char *old_base;
363 int size;
363# if FORKSHELL_DEBUG 364# if FORKSHELL_DEBUG
364 int funcblocksize; 365 int funcblocksize;
365 int funcstringsize; 366 int funcstringsize;
366 int relocatesize;
367# endif 367# endif
368 int size; 368 int relocatesize;
369 369
370 /* type of forkshell */ 370 /* type of forkshell */
371 int fpid; 371 int fpid;
@@ -15972,7 +15972,8 @@ forkshell_print(FILE *fp0, struct forkshell *fs, const char **notes)
15972 15972
15973 total = sizeof(struct forkshell) + fs->funcblocksize + 15973 total = sizeof(struct forkshell) + fs->funcblocksize +
15974 fs->funcstringsize + fs->relocatesize; 15974 fs->funcstringsize + fs->relocatesize;
15975 fprintf(fp, "total size %6d = %d + %d + %d + %d = %d\n", 2*fs->size, 15975 fprintf(fp, "total size %6d = %d + %d + %d + %d = %d\n",
15976 fs->size + fs->relocatesize,
15976 (int)sizeof(struct forkshell), fs->funcblocksize, 15977 (int)sizeof(struct forkshell), fs->funcblocksize,
15977 fs->funcstringsize, fs->relocatesize, total); 15978 fs->funcstringsize, fs->relocatesize, total);
15978 15979
@@ -16051,7 +16052,7 @@ static struct forkshell *
16051forkshell_prepare(struct forkshell *fs) 16052forkshell_prepare(struct forkshell *fs)
16052{ 16053{
16053 struct forkshell *new; 16054 struct forkshell *new;
16054 int size; 16055 int size, relocatesize;
16055 HANDLE h; 16056 HANDLE h;
16056 SECURITY_ATTRIBUTES sa; 16057 SECURITY_ATTRIBUTES sa;
16057#if FORKSHELL_DEBUG 16058#if FORKSHELL_DEBUG
@@ -16069,6 +16070,7 @@ forkshell_prepare(struct forkshell *fs)
16069 16070
16070 /* calculate size of structure, funcblock and funcstring */ 16071 /* calculate size of structure, funcblock and funcstring */
16071 size = sizeof(struct forkshell) + forkshell_size(fs); 16072 size = sizeof(struct forkshell) + forkshell_size(fs);
16073 relocatesize = size;
16072 16074
16073 /* Allocate shared memory region. We allocate twice 'size' to allow 16075 /* Allocate shared memory region. We allocate twice 'size' to allow
16074 * for the relocation map. This is an overestimate as the relocation 16076 * for the relocation map. This is an overestimate as the relocation
@@ -16078,7 +16080,8 @@ forkshell_prepare(struct forkshell *fs)
16078 sa.nLength = sizeof(sa); 16080 sa.nLength = sizeof(sa);
16079 sa.lpSecurityDescriptor = NULL; 16081 sa.lpSecurityDescriptor = NULL;
16080 sa.bInheritHandle = TRUE; 16082 sa.bInheritHandle = TRUE;
16081 h = CreateFileMapping(INVALID_HANDLE_VALUE, &sa, PAGE_READWRITE, 0, 2*size, NULL); 16083 h = CreateFileMapping(INVALID_HANDLE_VALUE, &sa, PAGE_READWRITE, 0,
16084 size+relocatesize, NULL);
16082 16085
16083 /* Initialise pointers */ 16086 /* Initialise pointers */
16084 new = (struct forkshell *)MapViewOfFile(h, FILE_MAP_WRITE, 0,0, 0); 16087 new = (struct forkshell *)MapViewOfFile(h, FILE_MAP_WRITE, 0,0, 0);
@@ -16086,7 +16089,7 @@ forkshell_prepare(struct forkshell *fs)
16086 funcblock = (char *)(new + 1); 16089 funcblock = (char *)(new + 1);
16087 funcstring_end = relocate = (char *)new + size; 16090 funcstring_end = relocate = (char *)new + size;
16088#if FORKSHELL_DEBUG 16091#if FORKSHELL_DEBUG
16089 annot = (const char **)xzalloc(sizeof(char *)*size); 16092 annot = (const char **)xzalloc(sizeof(char *)*relocatesize);
16090#endif 16093#endif
16091 16094
16092 /* Now pack them all */ 16095 /* Now pack them all */
@@ -16094,6 +16097,7 @@ forkshell_prepare(struct forkshell *fs)
16094 16097
16095 /* Finish it up */ 16098 /* Finish it up */
16096 new->size = size; 16099 new->size = size;
16100 new->relocatesize = relocatesize;
16097 new->old_base = (char *)new; 16101 new->old_base = (char *)new;
16098 new->hMapFile = h; 16102 new->hMapFile = h;
16099#if FORKSHELL_DEBUG 16103#if FORKSHELL_DEBUG
@@ -16103,7 +16107,6 @@ forkshell_prepare(struct forkshell *fs)
16103 16107
16104 new->funcblocksize = (char *)funcblock - (char *)(new + 1); 16108 new->funcblocksize = (char *)funcblock - (char *)(new + 1);
16105 new->funcstringsize = (char *)new + size - funcstring_end; 16109 new->funcstringsize = (char *)new + size - funcstring_end;
16106 new->relocatesize = size;
16107 16110
16108 /* perform some sanity checks on pointers */ 16111 /* perform some sanity checks on pointers */
16109 fprintf(fp, "forkshell %p %6d\n", new, (int)sizeof(*new)); 16112 fprintf(fp, "forkshell %p %6d\n", new, (int)sizeof(*new));
@@ -16116,7 +16119,7 @@ forkshell_prepare(struct forkshell *fs)
16116 16119
16117 forkshell_print(fp, new, annot); 16120 forkshell_print(fp, new, annot);
16118 16121
16119 for (i = 0; i < size; ++i) { 16122 for (i = 0; i < relocatesize; ++i) {
16120 if (relocate[i] == FREE) { 16123 if (relocate[i] == FREE) {
16121 free((void *)annot[i]); 16124 free((void *)annot[i]);
16122 } 16125 }
@@ -16165,7 +16168,7 @@ forkshell_init(const char *idstr)
16165 16168
16166 /* pointer fixup */ 16169 /* pointer fixup */
16167 lrelocate = (char *)fs + fs->size; 16170 lrelocate = (char *)fs + fs->size;
16168 for (i = 0; i < fs->size; i++) { 16171 for (i = 0; i < fs->relocatesize; i++) {
16169 if (lrelocate[i]) { 16172 if (lrelocate[i]) {
16170 ptr = (char **)((char *)fs + i); 16173 ptr = (char **)((char *)fs + i);
16171 if (*ptr) 16174 if (*ptr)