This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, gomp]: Reject negative values for env variables


On Thu, Oct 26, 2006 at 12:32:28PM +0200, Uros Bizjak wrote:
> 2006-10-26  Uros Bizjak  <uros@kss-loka.si>
> 
> 	* env.c (parse_schedule): Reject out of range or negative values.
> 	(parse_unsigned_long): Reject out of range, negative or zero values.

-  gomp_run_sched_chunk = strtoul (env, &end, 10);                                                                             
+  value = strtoul (env, &end, 10);                                                                                            
+  if (errno || (signed long) value < 0)                                                                                       
+    goto invalid;                                                                                                             
+                                                       

The errno checking is wrong, errno will very likely have undefined value
from some previous call.  If you want to check whether strtoul set errno,
you have to set it to 0 before the call:
  errno = 0;
  value = strtoul (env, &end, 10);
  if (errno || (long) value < 0)
    goto invalid;

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]