Commit 2cd264c7 authored by Jacek Kalwas's avatar Jacek Kalwas Committed by Jim Harris
Browse files

nvme: fix sscanf undef behavior

nvme_auth.c:293:40: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘int *’ [-Wformat=]
  293 |         rc = sscanf(keystr, "DHHC-1:%02x:", &hash);
      |                                     ~~~^    ~~~~~
      |                                        |    |
      |                                        |    int *
      |                                        unsigned int *
      |                                     %02x

Issue found when experimentally checked -Wpedantic flag on nvme library.
This flag also catches issue fixed here
https://review.spdk.io/c/spdk/spdk/+/25927


however besides these 2 it catches much more (~280).

Most of the issues discovered with -Wpedantinc (within nvme) are due to
forbidden zero-size array, invalid use of flexible array or empty
initializer braces.

Change-Id: I76ee208557dd605bbdedaa55d0aed82f95599365
Signed-off-by: default avatarJacek Kalwas <jacek.kalwas@nutanix.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/25930


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: default avatarAnkit Kumar <ankit.kumar@samsung.com>
Reviewed-by: default avatarChangpeng Liu <changpeliu@tencent.com>
parent 209a0cac
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ nvme_auth_get_seqnum(struct spdk_nvme_qpair *qpair)
}

static int
nvme_auth_transform_key(struct spdk_key *key, int hash, const char *nqn,
nvme_auth_transform_key(struct spdk_key *key, uint32_t hash, const char *nqn,
			const void *keyin, size_t keylen, void *out, size_t outlen)
{
	EVP_MAC *hmac = NULL;
@@ -279,7 +279,8 @@ nvme_auth_get_key(struct spdk_key *key, const char *nqn, void *buf, size_t bufle
	char keystr[NVME_AUTH_CHAP_KEY_MAX_SIZE + 1] = {};
	char keyb64[NVME_AUTH_CHAP_KEY_MAX_SIZE] = {};
	char *tmp, *secret;
	int rc, hash;
	uint32_t hash;
	int rc;
	size_t keylen;

	rc = spdk_key_get_key(key, keystr, NVME_AUTH_CHAP_KEY_MAX_SIZE);