git: 9front

Download patch

ref: 9444d3c603862b3096efb3d2f58fa11ce811c519
parent: f1e1e152eabad70fde645dd9cdf42536cdaa201f
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Aug 3 10:28:16 EDT 2015

webcookies: use strtol() to parse HH:MM:SS

atoi() currently interprets leading zeros as octal (BUG!),
so use strtol with explicit base 10 avoiding the issue.

--- a/sys/src/cmd/webcookies.c
+++ b/sys/src/cmd/webcookies.c
@@ -722,9 +722,9 @@
 		return -1;
 	}
 
-	tm.hour = atoi(s);
-	tm.min = atoi(s+3);
-	tm.sec = atoi(s+6);
+	tm.hour = strtol(s, 0, 10);
+	tm.min = strtol(s+3, 0, 10);
+	tm.sec = strtol(s+6, 0 10);
 	if(tm.hour >= 24 || tm.min >= 60 || tm.sec >= 60){
 		if(debug)
 			fprint(2, "invalid time (%s)\n", os);
--