Skip to contentSkip to conversation

9p: fix min_t() casting

PATCH In review Dan Carpenter 3 participants 4 messages Jan 15, 2011 – Jan 16, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 9p: fix min_t() casting

The intent here was to cap the length to USHRT_MAX, but what the code actually does is it just casts the return from strlen() to unsigned short and truncates the significant bits away.

net/9p/protocol.c +1 -1
index 1e308f2..0422581 100644
@@ -403,7 +403,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
 				const char *sptr = va_arg(ap, const char *);
 				uint16_t len = 0;
 				if (sptr)
-					len = min_t(uint16_t, strlen(sptr),
+					len = min_t(size_t, strlen(sptr),
 								USHRT_MAX);
 
 				errcode = p9pdu_writef(pdu, proto_version,
maintainer
#1 lore raw

From: Dan Carpenter <[email protected]>
Date: Sat, 15 Jan 2011 23:35:39 +0300

Quoted 5 lines

The intent here was to cap the length to USHRT_MAX, but what the code actually does is it just casts the return from strlen() to unsigned short and truncates the significant bits away.

If you want me to apply this, it doesn't apply cleanly to net-2.6 at all.

#2 lore raw
Quoted 11 lines · David Miller

From: Dan Carpenter <[email protected]>
Date: Sat, 15 Jan 2011 23:35:39 +0300

Quoted 5 lines

The intent here was to cap the length to USHRT_MAX, but what the code actually does is it just casts the return from strlen() to unsigned short and truncates the significant bits away.

If you want me to apply this, it doesn't apply cleanly to net-2.6 at all.

Sorry. I screwed up.

This was on top of a patch from M. Mohan Kumar <[email protected]> that hasn't hit net-2.6 yet. Mohan wasn't included on the CC list because get_maintainer.pl changed and I didn't notice and I wasn't careful.

Eric, could Mohan just fix his patch before it gets merged or is it better to send these as two patches?

regards,
dan carpenter

Ps: Mohon the patch is here:
http://marc.info/?l=linux-netdev&m9512381528034&w=2

#3 lore raw

The patch has already made it upstream via the v9fs pull. I'll pull in your fix Dan and request a second pull by Linus. Thanks for catching this.

-eric

Quoted 20 lines · Dan Carpenter
Quoted 11 lines · David Miller

From: Dan Carpenter <[email protected]>
Date: Sat, 15 Jan 2011 23:35:39 +0300

Quoted 5 lines

The intent here was to cap the length to USHRT_MAX, but what the code actually does is it just casts the return from strlen() to unsigned short and truncates the significant bits away.

If you want me to apply this, it doesn't apply cleanly to net-2.6 at all.

Sorry.  I screwed up.

This was on top of a patch from M. Mohan Kumar <[email protected]> that hasn't hit net-2.6 yet.  Mohan wasn't included on the CC list because get_maintainer.pl changed and I didn't notice and I wasn't careful.

Quoted 9 lines

Eric, could Mohan just fix his patch before it gets merged or is it better to send these as two patches?

regards,
dan carpenter

Ps:  Mohon the patch is here:
http://marc.info/?l=linux-netdev&m9512381528034&w=2

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html