summaryrefslogtreecommitdiff
path: root/libgomp/env.c
diff options
context:
space:
mode:
authoruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>2006-11-09 19:41:36 +0000
committeruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>2006-11-09 19:41:36 +0000
commit168d85f09c159297d8027526e8b3539191621f9a (patch)
tree7b24e95f788af258a0bf4ce1adb2f667e58293e5 /libgomp/env.c
parent6b6515433958c4d54e919788f276a04665ea6684 (diff)
downloadgcc-168d85f09c159297d8027526e8b3539191621f9a.tar.gz
* env.c (parse_schedule): Reject out of range values.
(parse_unsigned_long): Reject out of range, negative or zero values. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118626 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgomp/env.c')
-rw-r--r--libgomp/env.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/libgomp/env.c b/libgomp/env.c
index 0a80b87c5f5..af7e0c5c813 100644
--- a/libgomp/env.c
+++ b/libgomp/env.c
@@ -49,6 +49,7 @@ static void
parse_schedule (void)
{
char *env, *end;
+ unsigned long value;
env = getenv ("OMP_SCHEDULE");
if (env == NULL)
@@ -85,11 +86,17 @@ parse_schedule (void)
if (*env == '\0')
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))
++end;
if (*end != '\0')
goto invalid;
+
+ gomp_run_sched_chunk = value;
return;
unknown:
@@ -99,7 +106,6 @@ parse_schedule (void)
invalid:
gomp_error ("Invalid value for chunk size in "
"environment variable OMP_SCHEDULE");
- gomp_run_sched_chunk = 1;
return;
}
@@ -121,7 +127,11 @@ parse_unsigned_long (const char *name, unsigned long *pvalue)
if (*env == '\0')
goto invalid;
+ errno = 0;
value = strtoul (env, &end, 10);
+ if (errno || (long) value <= 0)
+ goto invalid;
+
while (isspace ((unsigned char) *end))
++end;
if (*end != '\0')