summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Winter <allen.winter@kdab.com>2022-06-02 07:44:48 -0400
committerAllen Winter <allen.winter@kdab.com>2022-06-02 07:44:48 -0400
commit4b5d892f9ec77985b4a313a4da8d8a0f43537f65 (patch)
treefa7ff11e991e75ef1581a28eba0e6d38cb567a14
parenta70844787b461cddcbc965c6a355eaff3e8bf052 (diff)
downloadlibical-git-4b5d892f9ec77985b4a313a4da8d8a0f43537f65.tar.gz
src/libical/icalvalue.c - fix format-truncation warning
-rw-r--r--src/libical/icalvalue.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libical/icalvalue.c b/src/libical/icalvalue.c
index 7a3c48e9..55921680 100644
--- a/src/libical/icalvalue.c
+++ b/src/libical/icalvalue.c
@@ -899,10 +899,13 @@ static char *icalvalue_utcoffset_as_ical_string_r(const icalvalue *value)
m = (data - (h * 3600)) / 60;
s = (data - (h * 3600) - (m * 60));
+ h = MIN(abs(h), 23);
+ m = MIN(abs(m), 59);
+ s = MIN(abs(s), 59);
if (s != 0) {
- snprintf(str, 9, "%c%02d%02d%02d", sign, abs(h), abs(m), abs(s));
+ snprintf(str, 9, "%c%02d%02d%02d", sign, h, m, s);
} else {
- snprintf(str, 9, "%c%02d%02d", sign, abs(h), abs(m));
+ snprintf(str, 9, "%c%02d%02d", sign, h, m);
}
return str;