From: Trond Myklebust <trond.myklebust@fys.uio.no>
To: David Howells <dhowells@redhat.com>
Cc: torvalds@osdl.org, akpm@osdl.org, aviro@redhat.com,
steved@redhat.com, linux-kernel@vger.kernel.org,
nfsv4@linux-nfs.org
Subject: Re: [PATCH] NFS: Check lengths more thoroughly in NFS4 readdir XDR decode
Date: Thu, 24 Aug 2006 15:32:54 -0400 [thread overview]
Message-ID: <1156447974.5629.54.camel@localhost> (raw)
In-Reply-To: <7346.1156444521@warthog.cambridge.redhat.com>
On Thu, 2006-08-24 at 19:35 +0100, David Howells wrote:
> So, what you've done is:
>
> -+ if (end - p < xlen)
> ++ if (end - p < xlen + 1)
> goto short_pkt;
> + dprintk("filename = %*s\n", len, (char *)p);
> + p += xlen;
> len = ntohl(*p++); /* bitmap length */
> - p += len;
> - if (p + 1 > end)
> -+ if (end - p < len)
> ++ if (end - p < len + 1)
> goto short_pkt;
> + p += len;
> attrlen = XDR_QUADLEN(ntohl(*p++));
> - p += attrlen; /* attributes */
> - if (p + 2 > end)
> -+ if (end - p < attrlen + 1)
> ++ if (end - p < attrlen + 2)
>
> But is this equivalent:
>
> -+ if (end - p < xlen)
> ++ if (end - p <= xlen)
> goto short_pkt;
> + dprintk("filename = %*s\n", len, (char *)p);
> + p += xlen;
> len = ntohl(*p++); /* bitmap length */
> - p += len;
> - if (p + 1 > end)
> -+ if (end - p < len)
> ++ if (end - p <= len)
> goto short_pkt;
> + p += len;
> attrlen = XDR_QUADLEN(ntohl(*p++));
> - p += attrlen; /* attributes */
> - if (p + 2 > end)
> -+ if (end - p < attrlen + 1)
> ++ if (end - p <= attrlen + 1)
^^^^^^^^^^^^^^
>
> Do you think?
No. I find that mixture of < and <= is much less easy to read. Besides,
the compiler should be able to optimise that for me.
Cheers,
Trond
next prev parent reply other threads:[~2006-08-24 19:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-22 16:19 [PATCH] NFS: Check lengths more thoroughly in NFS4 readdir XDR decode David Howells
2006-08-24 15:20 ` Trond Myklebust
2006-08-24 18:35 ` David Howells
2006-08-24 19:32 ` Trond Myklebust [this message]
2006-08-24 19:45 ` David Howells
2006-08-24 20:05 ` Trond Myklebust
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1156447974.5629.54.camel@localhost \
--to=trond.myklebust@fys.uio.no \
--cc=akpm@osdl.org \
--cc=aviro@redhat.com \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nfsv4@linux-nfs.org \
--cc=steved@redhat.com \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox