diff libtomcrypt/src/pk/asn1/der/utctime/der_decode_utctime.c @ 1471:6dba84798cd5

Update to libtomcrypt 1.18.1, merged with Dropbear changes
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 21:44:05 +0800
parents f849a5ca2efc
children
line wrap: on
line diff
--- a/libtomcrypt/src/pk/asn1/der/utctime/der_decode_utctime.c	Thu Feb 08 23:11:40 2018 +0800
+++ b/libtomcrypt/src/pk/asn1/der/utctime/der_decode_utctime.c	Fri Feb 09 21:44:05 2018 +0800
@@ -5,8 +5,6 @@
  *
  * The library is free for all purposes without any express
  * guarantee it works.
- *
- * Tom St Denis, [email protected], http://libtom.org
  */
 #include "tomcrypt.h"
 
@@ -17,7 +15,7 @@
 
 #ifdef LTC_DER
 
-static int char_to_int(unsigned char x)
+static int _char_to_int(unsigned char x)
 {
    switch (x)  {
       case '0': return 0;
@@ -30,12 +28,12 @@
       case '7': return 7;
       case '8': return 8;
       case '9': return 9;
+      default:  return 100;
    }
-   return 100;
 }
 
 #define DECODE_V(y, max) \
-   y  = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \
+   y  = _char_to_int(buf[x])*10 + _char_to_int(buf[x+1]); \
    if (y >= max) return CRYPT_INVALID_PACKET;           \
    x += 2;
 
@@ -49,7 +47,7 @@
 int der_decode_utctime(const unsigned char *in, unsigned long *inlen,
                              ltc_utctime   *out)
 {
-   unsigned char buf[32];
+   unsigned char buf[32] = { 0 }; /* initialize as all zeroes */
    unsigned long x;
    int           y;
 
@@ -73,7 +71,7 @@
    *inlen = 2 + x;
 
 
-   /* possible encodings are 
+   /* possible encodings are
 YYMMDDhhmmZ
 YYMMDDhhmm+hh'mm'
 YYMMDDhhmm-hh'mm'
@@ -81,7 +79,7 @@
 YYMMDDhhmmss+hh'mm'
 YYMMDDhhmmss-hh'mm'
 
-    So let's do a trivial decode upto [including] mm 
+    So let's do a trivial decode upto [including] mm
    */
 
     x = 0;
@@ -122,6 +120,6 @@
 
 #endif
 
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref:         $Format:%D$ */
+/* git commit:  $Format:%H$ */
+/* commit time: $Format:%ai$ */