summaryrefslogtreecommitdiff
path: root/src/libstrongswan/asn1
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2009-04-01 20:13:30 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2009-04-01 20:13:30 +0000
commitc3e7f611ea8273c6b3909cb006ade4903a74aad0 (patch)
treea5ae5b5059f98c0e5366d61b1b19cd9e70162f9f /src/libstrongswan/asn1
parent7a229aeb240cc750546f55ad089022f0ca7dc44f (diff)
downloadvyos-strongswan-c3e7f611ea8273c6b3909cb006ade4903a74aad0.tar.gz
vyos-strongswan-c3e7f611ea8273c6b3909cb006ade4903a74aad0.zip
[svn-upgrade] Integrating new upstream version, strongswan (4.2.14)
Diffstat (limited to 'src/libstrongswan/asn1')
-rw-r--r--src/libstrongswan/asn1/asn1.c23
-rw-r--r--src/libstrongswan/asn1/asn1.h10
-rw-r--r--src/libstrongswan/asn1/asn1_parser.h4
3 files changed, 21 insertions, 16 deletions
diff --git a/src/libstrongswan/asn1/asn1.c b/src/libstrongswan/asn1/asn1.c
index 1359dcd2d..8b9762777 100644
--- a/src/libstrongswan/asn1/asn1.c
+++ b/src/libstrongswan/asn1/asn1.c
@@ -14,7 +14,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: asn1.c 4942 2009-03-13 20:22:24Z andreas $
+ * $Id: asn1.c 5041 2009-03-27 08:58:48Z andreas $
*/
#include <stdio.h>
@@ -264,13 +264,15 @@ u_int asn1_length(chunk_t *blob)
return len;
}
+#define TIME_MAX 0x7fffffff
+
/**
* Converts ASN.1 UTCTIME or GENERALIZEDTIME into calender time
*/
time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
{
struct tm t;
- time_t tz_offset;
+ time_t tc, tz_offset;
u_char *eot = NULL;
if ((eot = memchr(utctime->ptr, 'Z', utctime->len)) != NULL)
@@ -296,12 +298,13 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
return 0; /* error in time format */
}
+ /* parse ASN.1 time string */
{
- const char* format = (type == ASN1_UTCTIME)? "%2d%2d%2d%2d%2d":
- "%4d%2d%2d%2d%2d";
+ const char* format = (type == ASN1_UTCTIME)? "%2d%2d%2d%2d%2d":
+ "%4d%2d%2d%2d%2d";
- sscanf(utctime->ptr, format, &t.tm_year, &t.tm_mon, &t.tm_mday,
- &t.tm_hour, &t.tm_min);
+ sscanf(utctime->ptr, format, &t.tm_year, &t.tm_mon, &t.tm_mday,
+ &t.tm_hour, &t.tm_min);
}
/* is there a seconds field? */
@@ -334,9 +337,11 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
/* set daylight saving time to off */
t.tm_isdst = 0;
- /* compensate timezone */
-
- return mktime(&t) - timezone - tz_offset;
+ /* convert to time_t */
+ tc = mktime(&t);
+
+ /* if no conversion overflow occurred, compensate timezone */
+ return (tc == -1) ? TIME_MAX : (tc - timezone - tz_offset);
}
/**
diff --git a/src/libstrongswan/asn1/asn1.h b/src/libstrongswan/asn1/asn1.h
index 0f2e6e5c0..4ea89730c 100644
--- a/src/libstrongswan/asn1/asn1.h
+++ b/src/libstrongswan/asn1/asn1.h
@@ -14,7 +14,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: asn1.h 3876 2008-04-26 09:24:14Z andreas $
+ * $Id: asn1.h 5003 2009-03-24 17:43:01Z martin $
*/
/**
@@ -110,7 +110,7 @@ int asn1_known_oid(chunk_t object);
* Returns the length of an ASN.1 object
* The blob pointer is advanced past the tag length fields
*
- * @param pointer to an ASN.1 coded blob
+ * @param blob pointer to an ASN.1 coded blob
* @return length of ASN.1 object
*/
u_int asn1_length(chunk_t *blob);
@@ -168,7 +168,7 @@ chunk_t asn1_from_time(const time_t *time, asn1_t type);
* Parse an ASN.1 UTCTIME or GENERALIZEDTIME object
*
* @param blob ASN.1 coded time object
- * @param level top-most level offset
+ * @param level0 top-most level offset
* @return time_t in UTC
*/
time_t asn1_parse_time(chunk_t blob, int level0);
@@ -223,10 +223,10 @@ chunk_t asn1_bitstring(const char *mode, chunk_t content);
/**
* Build an ASN.1 object from a variable number of individual chunks
*
- * @param typ ASN.1 type to be created
+ * @param type ASN.1 type to be created
* @param mode for each list member: 'c' for copy or 'm' for move
* @return chunk containing the ASN.1 coded object
*/
chunk_t asn1_wrap(asn1_t type, const char *mode, ...);
-#endif /* ASN1_H_ @}*/
+#endif /** ASN1_H_ @}*/
diff --git a/src/libstrongswan/asn1/asn1_parser.h b/src/libstrongswan/asn1/asn1_parser.h
index d84a5336f..bcc966e04 100644
--- a/src/libstrongswan/asn1/asn1_parser.h
+++ b/src/libstrongswan/asn1/asn1_parser.h
@@ -14,7 +14,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: asn1_parser.h 3894 2008-04-28 18:44:21Z andreas $
+ * $Id: asn1_parser.h 5003 2009-03-24 17:43:01Z martin $
*/
/**
@@ -116,4 +116,4 @@ struct asn1_parser_t {
*/
asn1_parser_t* asn1_parser_create(asn1Object_t const *objects, chunk_t blob);
-#endif /* ASN1_PARSER_H_ @}*/
+#endif /** ASN1_PARSER_H_ @}*/