Skip to content

fix(ots): use time_t for openssl_time_cb signature#406

Merged
zhaozg merged 1 commit intozhaozg:masterfrom
KritzelKratzel:fix_openssl_time_cb
Feb 24, 2026
Merged

fix(ots): use time_t for openssl_time_cb signature#406
zhaozg merged 1 commit intozhaozg:masterfrom
KritzelKratzel:fix_openssl_time_cb

Conversation

@KritzelKratzel
Copy link
Copy Markdown
Contributor

@KritzelKratzel KritzelKratzel commented Feb 23, 2026

Description

Compilation error on Windows x64 using Intel LLVM compiler:

[C:\...\intel]> cmake --build .
[24/41] Building C object CMakeFiles\lua-openssl.dir\src\ots.c.obj
FAILED: CMakeFiles/lua-openssl.dir/src/ots.c.obj
C:\PROGRA~2\Intel\oneAPI\compiler\latest\bin\icx.exe  /nologo -DLUA_BUILD_AS_DLL -DOPENSSL_SYS_WIN32 -DWIN32_LEAN_AND_MEAN -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -Dlua_openssl_EXPORTS -Dssize_t=SSIZE_T -IC:\misc\OneLuaPro\intel\ONELUAPRO_BUILDROOT\include -IC:\misc\_IMPLEMENTED\lua-openssl\deps -IC:\misc\_IMPLEMENTED\lua-openssl\deps\lua-compat\c-api -IC:\misc\_IMPLEMENTED\lua-openssl\deps\auxiliar /QxHost /O2 /Ob2 /DNDEBUG -MT -Wno-unused-command-line-argument -Wno-comment -DLUA_LIB -QMD -QMT CMakeFiles\lua-openssl.dir\src\ots.c.obj -QMF CMakeFiles\lua-openssl.dir\src\ots.c.obj.d /FoCMakeFiles\lua-openssl.dir\src\ots.c.obj /FdCMakeFiles\lua-openssl.dir\ -c C:\misc\_IMPLEMENTED\lua-openssl\src\ots.c
C:\misc\_IMPLEMENTED\lua-openssl\src\ots.c(1581,32): error: incompatible function pointer types passing 'int (TS_RESP_CTX *, void *, long *, long *)' (aka 'int (struct TS_resp_ctx *, void *, long *, long *)') to parameter of type 'TS_time_cb' (aka 'int (*)(struct TS_resp_ctx *, void *, long long *, long *)') [-Wincompatible-function-pointer-types]
 1581 |   TS_RESP_CTX_set_time_cb(ctx, openssl_time_cb, openssl_mainthread(L));
      |                                ^~~~~~~~~~~~~~~
C:\misc\OneLuaPro\intel\ONELUAPRO_BUILDROOT\include\openssl\ts.h(402,59): note: passing argument to parameter 'cb' here
  402 | void TS_RESP_CTX_set_time_cb(TS_RESP_CTX *ctx, TS_time_cb cb, void *data);
      |                                                           ^
1 error generated.
[31/41] Building C object CMakeFiles\lua-openssl.dir\src\srp.c.obj
ninja: build stopped: subcommand failed.

[C:\...\intel]>

Related Issue

None.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Code review/analysis
  • Performance improvement
  • Code refactoring
  • Other (please describe)

Changes Made

Updated openssl_time_cb() to use time_t* for the seconds parameter to match LibreSSL 4.2.1's TS_time_cb definition. This fixes incompatible function pointer errors on Windows x64 using IntelLLVM compiler. See openssl/ts.h.

/* This must return the seconds and microseconds since Jan 1, 1970 in
   the sec and usec variables allocated by the caller.
   Return non-zero for success and zero for failure. */
typedef	int (*TS_time_cb)(struct TS_resp_ctx *, void *, time_t *sec, long *usec);

Testing

Please describe the tests you ran to verify your changes:

  • Existing tests pass
  • Added new tests
  • Manual testing performed

Checklist

  • My code follows the style guidelines of this project (clang-format)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

OpenSSL Compatibility

Please indicate which OpenSSL versions were tested (if applicable):

  • OpenSSL 1.0.2u
  • OpenSSL 1.1.1w
  • OpenSSL 3.0.x
  • OpenSSL 3.5+
  • LibreSSL 3.3.6+
  • LibreSSL 4.2.1

Additional Notes

None.

Updated openssl_time_cb to use time_t* for the seconds parameter
to match LibreSSL 4.2.1's TS_time_cb definition. This fixes
incompatible function pointer errors on Windows x64 using IntelLLVM compiler.
@zhaozg zhaozg merged commit 8ec2fe4 into zhaozg:master Feb 24, 2026
52 of 57 checks passed
@zhaozg
Copy link
Copy Markdown
Owner

zhaozg commented Feb 24, 2026

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants