ldb: ldb_string_to_time reports more errors
commit8892b0cc92650c20f908f1076677ab4c2b6cc418
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 14 Feb 2024 01:20:28 +0000 (14 14:20 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 29 Feb 2024 04:01:40 +0000 (29 04:01 +0000)
tree997f4ae73a634b6b457b4dee8b5185d29b203b44
parent9beb57892db1e4056a038519961cc657cf7a744f
ldb: ldb_string_to_time reports more errors

The underlying function should return -1 and set errno when given invalid
strings, but we were not looking and have decided on 0 for error.

It would be a pain to change this function to return -1. Apart from the
API fuss, it is sometimes used unchecked to set an unsigned number and
an unchecked 0 is better than UINT*_MAX in those contexts.

It is probably not easy to get an -1 from a timegm() -- most
implementations will happily convert overflows for you, so e.g. the
15th month would be March of the next year. But EOVERFLOW is mentioned
in the manpages.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/common/ldb_msg.c
lib/ldb/tests/python/api.py