Skip to content
Myr

Fixes CVE-2025-49014 which was introduced in 1.8.0

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Mattias Wadman · committed by itchyny · parent edbc1da · Browse files · 2 files+12 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+12 added−2 removed

  • tests:+8 added−0 removed
  • other:+4 added−2 removed

2 files+12 added−2 removed

modified:src/builtin.c+4 added-2 removed
1762 unmodified lines
1763 if (!jv2tm(a, &tm, 0))1764 return ret_error(b, jv_string("strftime/1 requires parsed datetime inputs"));17651766 const char *fmt = jv_string_value(b);1767 int fmt_not_empty = *fmt != '\0';1768 size_t max_size = strlen(fmt) + 100;1769 char *buf = jv_mem_alloc(max_size);1770#ifdef __APPLE__1771 /* Apple Libc (as of version 1669.40.2) contains a bug which causes it to
12 unmodified lines
1784 }1785#endif1786 jv_free(b);1787 /* POSIX doesn't provide errno values for strftime() failures; weird */1787 if ((n == 0 && *fmt) || n > max_size) {1788 if ((n == 0 && fmt_not_empty) || n > max_size) {1789 free(buf);1790 return jv_invalid_with_msg(jv_string("strftime/1: unknown system failure"));1791 }1792 jv ret = jv_string_sized(buf, n);
20 unmodified lines
1813 struct tm tm;1814 if (!jv2tm(a, &tm, 1))1815 return ret_error(b, jv_string("strflocaltime/1 requires parsed datetime inputs"));1816 const char *fmt = jv_string_value(b);1817 int fmt_not_empty = *fmt != '\0';1818 size_t max_size = strlen(fmt) + 100;1819 char *buf = jv_mem_alloc(max_size);1820 size_t n = strftime(buf, max_size, fmt, &tm);1821 jv_free(b);1822 /* POSIX doesn't provide errno values for strftime() failures; weird */1821 if ((n == 0 && *fmt) || n > max_size) {1823 if ((n == 0 && fmt_not_empty) || n > max_size) {1824 free(buf);1825 return jv_invalid_with_msg(jv_string("strflocaltime/1: unknown system failure"));1826 }1827 jv ret = jv_string_sized(buf, n);
244 unmodified lines
modified:tests/jq.test+8 added
2497 unmodified lines
2498124993250022501425022503# regression test for CVE-2025-49014 (use of fmt after free)2504# tests with both empty string literal and empty string created by function2505# as they seems to behave referecne wise differently.2506strflocaltime("" | ., @uri)250702508""2509""