net/ceph/ceph_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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
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
© 2016 - 2025 Red Hat, Inc.