summaryrefslogtreecommitdiff
path: root/lib/ldb/common/ldb_msg.c
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2012-05-17 23:57:55 -0700
committerMatthieu Patou <mat@matws.net>2012-06-22 23:22:03 -0700
commit1c850b2f173678b0df7a2619024baf2d94011a7b (patch)
tree0817beac84234110e08d3d0edca0052aa7a8a4de /lib/ldb/common/ldb_msg.c
parent884d66d959e2eaa384bf9af6230ffb589a581b13 (diff)
downloadsamba-1c850b2f173678b0df7a2619024baf2d94011a7b.tar.gz
samba-1c850b2f173678b0df7a2619024baf2d94011a7b.tar.bz2
samba-1c850b2f173678b0df7a2619024baf2d94011a7b.zip
ldb: lay foundation for proper utc/generalized time handling
We use to handle UTCtime and generalized time the same way. The thing is that it's not the case, they are different in the way they are set (most of the time) with different format and also stored and return in different format too.
Diffstat (limited to 'lib/ldb/common/ldb_msg.c')
-rw-r--r--lib/ldb/common/ldb_msg.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/ldb/common/ldb_msg.c b/lib/ldb/common/ldb_msg.c
index 35c568a077..809e3af819 100644
--- a/lib/ldb/common/ldb_msg.c
+++ b/lib/ldb/common/ldb_msg.c
@@ -1092,16 +1092,24 @@ int ldb_val_to_time(const struct ldb_val *v, time_t *t)
{
struct tm tm;
- if (v == NULL || !v->data || v->length < 17) {
+ if (v == NULL || !v->data || (v->length != 17 && v->length != 13)) {
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
memset(&tm, 0, sizeof(tm));
- if (sscanf((char *)v->data, "%04u%02u%02u%02u%02u%02u.0Z",
- &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
- &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
- return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
+ if (v->length == 13) {
+ if (sscanf((char *)v->data, "%02u%02u%02u%02u%02u%02uZ",
+ &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
+ &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
+ return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
+ }
+ } else {
+ if (sscanf((char *)v->data, "%04u%02u%02u%02u%02u%02u.0Z",
+ &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
+ &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
+ return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
+ }
}
tm.tm_year -= 1900;
tm.tm_mon -= 1;