Skip to content

Conversation

twilfredo
Copy link
Contributor

@twilfredo twilfredo commented Aug 12, 2025

Fixes the following compile errors when HAVE_GNUTLS_PSK_ALLOCATE_CREDENTIALS2 is enabled.

client.c:369:40: error: format ‘%c’ expects argument of type ‘char *’,
but argument 4 has type ‘int *’ [-Werror=format=]
  369 |         if (sscanf(identity, "NVMe%01d%c%02d %*s",
      |                                       ~^
      |                                        |
      |                                        char *
      |                                       %lc
  370 |                    &version, &type, &hash) == 3) {
      |                              ~~~~~
      |                              |
      |                              int *
server.c: In function ‘tlshd_tls13_server_psk_handshake’:
server.c:332:55: error: ‘GNUTLS_MAC_NONE’ undeclared
(first use in this function); did you mean ‘GNUTLS_EXT_NONE’?
  332 |                                                       GNUTLS_MAC_NONE);
      |                                                       ^~~~~~~~~~~~~~~
      |                                                       GNUTLS_EXT_NONE

Note that gnutls_psk_allocate_server_credentials2() accepts one of
GNUTLS_MAC_UNKNOWN, GNUTLS_MAC_SHA256 or GNUTLS_MAC_SHA384 as the
mac argument. Currently, GNUTLS_MAC_NONE does not exist in GnuTLS,
this patch changes this invalid type to GNUTLS_MAC_UNKNOWN.

Fixes: a5a25e9 ("tlshd: use gnutls_psk_allocate_{client,server}_credentials2")

Copy link
Member

@chucklever chucklever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the Linux kernel's style for the Fixes: tag:

Fixes: a5a25e9 ("tlshd: use gnutls_psk_allocate_{client,server}_credentials2")

No empty line between Fixes: and Signed-off-by.

I want to consult with Hannes about GNUTLS_MAC_NONE. Could be that he just guessed at what that symbol would be named, but I'd like to make sure. If you actually know the answer to that, please mention it in your patch description.

Thanks for the submission!

@twilfredo twilfredo force-pushed the wilfred/fixup-psk-compile branch from 72d08cf to 4333cb5 Compare August 13, 2025 05:58
@twilfredo
Copy link
Contributor Author

twilfredo commented Aug 13, 2025

Please use the Linux kernel's style for the Fixes: tag:

Fixes: a5a25e9 ("tlshd: use gnutls_psk_allocate_{client,server}_credentials2")

No empty line between Fixes: and Signed-off-by.

Thanks, I have amended the commit message.

I want to consult with Hannes about GNUTLS_MAC_NONE. Could be that he just guessed at what that symbol would be named, but I'd like to make sure. If you actually know the answer to that, please mention it in your patch description.

It would indeed be good to double check with Hannes. The gnutls_psk_allocate_server_credentials2() function accepts 3 arguments for the mac argument. Those are GNUTLS_MAC_UNKNOWN, GNUTLS_MAC_SHA256 and GNUTLS_MAC_SHA384 [1]. So in this context, I thought GNUTLS_MAC_UNKNOWN made sense.

However, using GNUTLS_MAC_UNKNOWN also does cause other issues in GnuTLS, which will need to be addressed there [2].

[1] https://gitlab.com/gnutls/gnutls/-/blob/master/lib/psk.c#L244
[2] https://gitlab.com/gnutls/gnutls/-/issues/1729

Thanks for the submission!

Fixes the following compile errors when HAVE_GNUTLS_PSK_ALLOCATE_CREDENTIALS2 is
enabled.

```
client.c:369:40: error: format ‘%c’ expects argument of type ‘char *’,
but argument 4 has type ‘int *’ [-Werror=format=]
  369 |         if (sscanf(identity, "NVMe%01d%c%02d %*s",
      |                                       ~^
      |                                        |
      |                                        char *
      |                                       %lc
  370 |                    &version, &type, &hash) == 3) {
      |                              ~~~~~
      |                              |
      |                              int *
server.c: In function ‘tlshd_tls13_server_psk_handshake’:
server.c:332:55: error: ‘GNUTLS_MAC_NONE’ undeclared
(first use in this function); did you mean ‘GNUTLS_EXT_NONE’?
  332 |                                                       GNUTLS_MAC_NONE);
      |                                                       ^~~~~~~~~~~~~~~
      |                                                       GNUTLS_EXT_NONE

```

Note that `gnutls_psk_allocate_server_credentials2()` accepts one of
`GNUTLS_MAC_UNKNOWN`, `GNUTLS_MAC_SHA256` or `GNUTLS_MAC_SHA384` as the
`mac` argument. Currently, `GNUTLS_MAC_NONE` does not exist in GnuTLS,
this patch changes this invalid type to `GNUTLS_MAC_UNKNOWN`.

Fixes: a5a25e9 ("tlshd: use gnutls_psk_allocate_{client,server}_credentials2")
Signed-off-by: Wilfred Mallawa <[email protected]>
@twilfredo twilfredo force-pushed the wilfred/fixup-psk-compile branch from 4333cb5 to dd10615 Compare August 13, 2025 06:13
Copy link
Contributor

@hreinecke hreinecke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Signed-off-by: Hannes Reinecke <[email protected]

@chucklever chucklever merged commit 40390f3 into oracle:main Aug 18, 2025
4 checks passed
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.

3 participants