From: Kenichi Handa <handa@m17n.org>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: emacs-devel@gnu.org
Subject: Re: Use of memcmp in font.c
Date: Wed, 11 Jun 2008 10:07:38 +0900 [thread overview]
Message-ID: <E1K6EoM-0002o3-L1@etlken.m17n.org> (raw)
In-Reply-To: <87ve0iqnnq.fsf@stupidchicken.com> (message from Chong Yidong on Mon, 09 Jun 2008 17:55:05 -0400)
In article <87ve0iqnnq.fsf@stupidchicken.com>, Chong Yidong <cyd@stupidchicken.com> writes:
> Is the use of memcmp in font.c:1384 safe? It seems to me that if the
> string being parsed ends early, we'll get a segmentation fault.
> /* Now parse ":KEY=VAL" patterns. Store known keys and values in
> extra, copy unknown ones to COPY. It is stored in extra slot by
> the key QCfc_unknown_spec. */
> while (*p0)
> {
> Lisp_Object key, val;
> int prop;
> for (p1 = p0 + 1; *p1 && *p1 != '=' && *p1 != ':'; p1++);
> if (*p1 != '=')
> {
> /* Must be an enumerated value. */
> val = font_intern_prop (p0 + 1, p1 - p0 - 1);
> if (memcmp (p0 + 1, "light", 5) == 0
> || memcmp (p0 + 1, "medium", 6) == 0
> .....
I've thought that memcmp doesn't check bytes after the first
non-matching byte and thus the above are safe because p0 is
null-terminated.
---
Kenichi Handa
handa@ni.aist.go.jp
next prev parent reply other threads:[~2008-06-11 1:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-09 21:55 Use of memcmp in font.c Chong Yidong
2008-06-11 1:07 ` Kenichi Handa [this message]
2008-06-11 1:12 ` Miles Bader
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1K6EoM-0002o3-L1@etlken.m17n.org \
--to=handa@m17n.org \
--cc=cyd@stupidchicken.com \
--cc=emacs-devel@gnu.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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).