Sfoglia il codice sorgente

Fix possible overflow in code_timespec (tiny change)

* src/misc.c (code_timespec): ignore invalid values of ns
Kamil Dudka 15 anni fa
parent
commit
46b07a52f9
1 ha cambiato i file con 4 aggiunte e 0 eliminazioni
  1. 4 0
      src/misc.c

+ 4 - 0
src/misc.c

@@ -298,6 +298,10 @@ code_timespec (struct timespec t, char sbuf[TIMESPEC_STRSIZE_BOUND])
   char *np;
   bool negative = s < 0;
 
+  /* ignore invalid values of ns */
+  if (BILLION <= ns || ns < 0)
+    ns = 0;
+  
   if (negative && ns != 0)
     {
       s++;