This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch release/9.1
in repository ffmpeg.

commit cc86c4abc713e0ce9e60208763f655fa897adc58
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Wed Nov 11 04:32:57 2026 +0100
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Thu Nov 19 14:56:30 2026 +0100

    avutil/parseutils: saturate av_timegm() to the range of time_t
    
    With a 32 bit time_t a date after 2038 wrapped around, so a cookie
    expiring in 2100 was treated as expired.
    
    Fixes: av_timegm() overflow with a 32 bit time_t
    (cherry picked from commit a2ad4447c8253f308dafdfa812b3cd519dcdbbfd)
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavutil/parseutils.c | 8 +++++++-
 libavutil/parseutils.h | 3 ++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index 9f57b16ec2..acdc148c58 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -572,7 +572,7 @@ char *av_small_strptime(const char *p, const char *fmt, 
struct tm *dt)
 
 time_t av_timegm(struct tm *tm)
 {
-    time_t t;
+    int64_t t;
 
     int y = tm->tm_year + 1900, m = tm->tm_mon + 1, d = tm->tm_mday;
 
@@ -586,6 +586,12 @@ time_t av_timegm(struct tm *tm)
 
     t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec;
 
+    // saturate if time_t cannot hold the result
+    if ((time_t)t != t) {
+        const time_t max = (time_t)-1 < 0 ? (time_t)(INT64_MAX >> (64 - 8 * 
sizeof(time_t))) : (time_t)-1;
+        return t > 0 ? max : (time_t)-1 < 0 ? -max - 1 : 0;
+    }
+
     return t;
 }
 
diff --git a/libavutil/parseutils.h b/libavutil/parseutils.h
index dad5c2775b..9d5ea2638a 100644
--- a/libavutil/parseutils.h
+++ b/libavutil/parseutils.h
@@ -190,7 +190,8 @@ int av_find_info_tag(char *arg, int arg_size, const char 
*tag1, const char *info
 char *av_small_strptime(const char *p, const char *fmt, struct tm *dt);
 
 /**
- * Convert the decomposed UTC time in tm to a time_t value.
+ * Convert the decomposed UTC time in tm to a time_t value, saturated to the
+ * range of time_t.
  */
 time_t av_timegm(struct tm *tm);
 

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to