Commit 6acf0b38 by Uros Bizjak Committed by Uros Bizjak

env.c (parse_schedule): Reject out of range values.

        * env.c (parse_schedule): Reject out of range values.
        (parse_unsigned_long): Reject out of range, negative or zero values.

From-SVN: r118626
parent 0ad12cd3
2006-11-09 Uros Bizjak <ubizjak@gmail.com>
* env.c (parse_schedule): Reject out of range values.
(parse_unsigned_long): Reject out of range, negative or zero values.
2006-10-29 Jakub Jelinek <jakub@redhat.com> 2006-10-29 Jakub Jelinek <jakub@redhat.com>
PR fortran/29629 PR fortran/29629
......
...@@ -49,6 +49,7 @@ static void ...@@ -49,6 +49,7 @@ static void
parse_schedule (void) parse_schedule (void)
{ {
char *env, *end; char *env, *end;
unsigned long value;
env = getenv ("OMP_SCHEDULE"); env = getenv ("OMP_SCHEDULE");
if (env == NULL) if (env == NULL)
...@@ -85,11 +86,17 @@ parse_schedule (void) ...@@ -85,11 +86,17 @@ parse_schedule (void)
if (*env == '\0') if (*env == '\0')
goto invalid; goto invalid;
gomp_run_sched_chunk = strtoul (env, &end, 10); errno = 0;
value = strtoul (env, &end, 10);
if (errno)
goto invalid;
while (isspace ((unsigned char) *end)) while (isspace ((unsigned char) *end))
++end; ++end;
if (*end != '\0') if (*end != '\0')
goto invalid; goto invalid;
gomp_run_sched_chunk = value;
return; return;
unknown: unknown:
...@@ -99,7 +106,6 @@ parse_schedule (void) ...@@ -99,7 +106,6 @@ parse_schedule (void)
invalid: invalid:
gomp_error ("Invalid value for chunk size in " gomp_error ("Invalid value for chunk size in "
"environment variable OMP_SCHEDULE"); "environment variable OMP_SCHEDULE");
gomp_run_sched_chunk = 1;
return; return;
} }
...@@ -121,7 +127,11 @@ parse_unsigned_long (const char *name, unsigned long *pvalue) ...@@ -121,7 +127,11 @@ parse_unsigned_long (const char *name, unsigned long *pvalue)
if (*env == '\0') if (*env == '\0')
goto invalid; goto invalid;
errno = 0;
value = strtoul (env, &end, 10); value = strtoul (env, &end, 10);
if (errno || (long) value <= 0)
goto invalid;
while (isspace ((unsigned char) *end)) while (isspace ((unsigned char) *end))
++end; ++end;
if (*end != '\0') if (*end != '\0')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment