mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ceph: Fix the wrong format specifier
@ 2025-09-19  3:27 liujing
  2025-09-19 18:38 ` Viacheslav Dubeyko
  0 siblings, 1 reply; 2+ messages in thread
From: liujing @ 2025-09-19  3:27 UTC (permalink / raw)
  To: idryomov; +Cc: xiubli, ceph-devel, linux-kernel, liujing

in the ceph_common.c file, to strictly comply with the requirements
of the %x format specifier and avoid type mismatch and overflow
issues, d should be defined as an unsigned int type.

Signed-off-by: liujing <liujing@cmss.chinamobile.com>
---
 net/ceph/ceph_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
index 4c6441536d55..d3c19a63cadd 100644
--- a/net/ceph/ceph_common.c
+++ b/net/ceph/ceph_common.c
@@ -195,7 +195,7 @@ int ceph_parse_fsid(const char *str, struct ceph_fsid *fsid)
 	int i = 0;
 	char tmp[3];
 	int err = -EINVAL;
-	int d;
+	unsigned int d;
 
 	dout("%s '%s'\n", __func__, str);
 	tmp[2] = 0;
-- 
2.27.0




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re:  [PATCH] ceph: Fix the wrong format specifier
  2025-09-19  3:27 [PATCH] ceph: Fix the wrong format specifier liujing
@ 2025-09-19 18:38 ` Viacheslav Dubeyko
  0 siblings, 0 replies; 2+ messages in thread
From: Viacheslav Dubeyko @ 2025-09-19 18:38 UTC (permalink / raw)
  To: idryomov, liujing; +Cc: Xiubo Li, ceph-devel, linux-kernel

On Fri, 2025-09-19 at 11:27 +0800, liujing wrote:
> in the ceph_common.c file, to strictly comply with the requirements
> of the %x format specifier and avoid type mismatch and overflow
> issues, d should be defined as an unsigned int type.
> 
> Signed-off-by: liujing <liujing@cmss.chinamobile.com>
> ---
>  net/ceph/ceph_common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
> index 4c6441536d55..d3c19a63cadd 100644
> --- a/net/ceph/ceph_common.c
> +++ b/net/ceph/ceph_common.c
> @@ -195,7 +195,7 @@ int ceph_parse_fsid(const char *str, struct ceph_fsid *fsid)
>  	int i = 0;
>  	char tmp[3];
>  	int err = -EINVAL;
> -	int d;
> +	unsigned int d;
>  
>  	dout("%s '%s'\n", __func__, str);
>  	tmp[2] = 0;

The main action happens here [1]:

tmp[0] = str[0];
tmp[1] = str[1];
if (sscanf(tmp, "%x", &d) < 1)
	break;
fsid->fsid[i] = d & 0xff;

So, tmp is two symbols array with terminating '\0' symbol.
Finally, we make conversion of two digits (or two bytes) string
into the number. The maximum possible number could be 0xFFFF (65535).
Frankly speaking, I don't see how we can have the overflow issue here.
Could you please explain more clearly your point?

Thanks,
Slava.

[1] 
https://elixir.bootlin.com/linux/v6.17-rc6/source/net/ceph/ceph_common.c#L211

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-19 18:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-19  3:27 [PATCH] ceph: Fix the wrong format specifier liujing
2025-09-19 18:38 ` Viacheslav Dubeyko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®