X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fruntime.c;h=4c1ea7130e02a5fd7298e1080210f6228450c4d5;hb=1439811447104b32d986bab40d6e2ed431247004;hp=d03cd8d789870df0ebdb6196ca8d09cf6354fad2;hpb=e05f13837227104f8fa3441ff1085982fab20e2c;p=sbcl.git diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index d03cd8d..4c1ea71 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -394,16 +394,23 @@ main(int argc, char *argv[], char *envp[]) ++argi; if (argi >= argc) lose("missing argument for --dynamic-space-size"); - errno = 0; - dynamic_space_size = strtol(argv[argi++], 0, 0) << 20; - if (errno) - lose("argument to --dynamic-space-size is not a number"); + { + char *tail; + long tmp = strtol(argv[argi++], &tail, 0); + if (tail[0]) + lose("--dynamic-space-size argument is not a number"); + if ((tmp <= 0) || + (tmp >= (LONG_MAX >> 20))) { + lose("--dynamic-space-size argument is out of range"); + } + dynamic_space_size = tmp << 20; + } # ifdef MAX_DYNAMIC_SPACE_END if (!((DYNAMIC_SPACE_START < DYNAMIC_SPACE_START+dynamic_space_size) && (DYNAMIC_SPACE_START+dynamic_space_size <= MAX_DYNAMIC_SPACE_END))) - lose("specified --dynamic-space-size too large"); + lose("--dynamic-space-size argument is too large"); # endif } else if (0 == strcmp(arg, "--control-stack-size")) { ++argi;