Opened 6 months ago

Closed 5 months ago

Last modified 5 months ago

#69624 closed defect (fixed)

mbedtls3 @3.6.0 uses wrong number of args to memcpy: error: macro "memcpy" requires 3 arguments, but only 2 given

Reported by: barracuda156 Owned by: Schamschula (Marius Schamschula)
Priority: Normal Milestone:
Component: ports Version: 2.9.1
Keywords: Cc:
Port: mbedtls3

Description

/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/ssl_tls13_generic.c:196:79: error: macro "memcpy" requires 3 arguments, but only 2 given
  196 |         memcpy(verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN(client_cv));
      |                                                                               ^
In file included from /usr/include/string.h:148,
                 from /opt/local/include/LegacySupport/string.h:25,
                 from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/alignment.h:15,
                 from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/common.h:15,
                 from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/ssl_tls13_generic.c:8:
/usr/include/secure/_string.h:50: note: macro "memcpy" defined here
   50 | #define memcpy(dest, src, len)                                  \
      | 
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/ssl_tls13_generic.c:196:9: warning: statement with no effect [-Wunused-value]
  196 |         memcpy(verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN(client_cv));
      |         ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/ssl_tls13_generic.c:199:79: error: macro "memcpy" requires 3 arguments, but only 2 given
  199 |         memcpy(verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN(server_cv));
      |                                                                               ^
/usr/include/secure/_string.h:50: note: macro "memcpy" defined here
   50 | #define memcpy(dest, src, len)                                  \
      | 
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/ssl_tls13_generic.c:199:9: warning: statement with no effect [-Wunused-value]
  199 |         memcpy(verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN(server_cv));
      |         ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/ssl_tls13_generic.c: In function 'ssl_tls13_create_verify_structure':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/ssl_tls13_generic.c:196:79: error: macro "memcpy" requires 3 arguments, but only 2 given
  196 |         memcpy(verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN(client_cv));
      |                                                                               ^
In file included from /usr/include/string.h:148,
                 from /opt/local/include/LegacySupport/string.h:25,
                 from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/alignment.h:15,
                 from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/common.h:15,
                 from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/ssl_tls13_generic.c:8:
/usr/include/secure/_string.h:50: note: macro "memcpy" defined here
   50 | #define memcpy(dest, src, len)                                  \
      | 
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/ssl_tls13_generic.c:196:9: warning: statement with no effect [-Wunused-value]
  196 |         memcpy(verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN(client_cv));
      |         ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/ssl_tls13_generic.c:199:79: error: macro "memcpy" requires 3 arguments, but only 2 given
  199 |         memcpy(verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN(server_cv));
      |                                                                               ^
/usr/include/secure/_string.h:50: note: macro "memcpy" defined here
   50 | #define memcpy(dest, src, len)                                  \
      | 
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_mbedtls3/mbedtls3/work/mbedtls-3.6.0/library/ssl_tls13_generic.c:199:9: warning: statement with no effect [-Wunused-value]
  199 |         memcpy(verify_buffer + idx, MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN(server_cv));
      |         ^~~~~~
make[2]: *** [library/CMakeFiles/mbedtls_static.dir/ssl_tls13_generic.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....

Change History (8)

comment:1 Changed 6 months ago by Schamschula (Marius Schamschula)

This error is for Sierra and below. My guess is that we need to blacklist compiler(s).

comment:2 Changed 6 months ago by ryandesign (Ryan Carsten Schmidt)

Cc: Schamschula removed
Owner: set to Schamschula
Status: newassigned

See https://github.com/Mbed-TLS/mbedtls/issues/8994

The problem is a system header so I don't think using a different compiler would help (but if you find out otherwise let us know).

comment:3 Changed 6 months ago by Schamschula (Marius Schamschula)

So is it something the legacysupport PG can address?

comment:4 Changed 6 months ago by Schamschula (Marius Schamschula)

I guess not.

comment:5 Changed 6 months ago by kencu (Ken)

the definition of memcpy changed from this

https://github.com/alexey-lysiuk/macos-sdk/blob/2e3a0a902a4d8e641d44224ef2860a4f1ebfd9d7/MacOSX10.11.sdk/usr/include/secure/_string.h#L63

to this

https://github.com/alexey-lysiuk/macos-sdk/blob/2e3a0a902a4d8e641d44224ef2860a4f1ebfd9d7/MacOSX10.13.sdk/usr/include/secure/_string.h#L61

and the second definition seems more lax on the number of arguments…

Not sure how it can ever be right to call memcpy with 2 args though… wonder why they loosened up on that?

comment:6 Changed 6 months ago by jmroot (Joshua Root)

The apparent second argument MBEDTLS_SSL_TLS1_3_LBL_WITH_LEN is actually a macro that is supposed to expand to two args. I think they didn't account for memcpy itself sometimes being a macro.

comment:7 Changed 5 months ago by barracuda156

Resolution: fixed
Status: assignedclosed

In 5cf6da2bf95edba5bed039b1b2a1c2aed02c1a19/macports-ports (master):

mbedtls3: backport upstream fix for builds on < 10.13

Closes: #69624

comment:8 in reply to:  5 Changed 5 months ago by kencu (Ken)

Replying to kencu:

Not sure how it can ever be right to call memcpy with 2 args though… wonder why they loosened up on that?

the third arg (size) to memcpy and friends is now calculated at compile time from the size of the first object, rather than accepting the size that is passed in by the caller, which I suppose may be wrong and open up a security hole.

https://stackoverflow.com/questions/74756914/what-are-darwin-obsz-and-darwin-obsz0

Note: See TracTickets for help on using tickets.