[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Use of memcmp in font.c
From: |
Kenichi Handa |
Subject: |
Re: Use of memcmp in font.c |
Date: |
Wed, 11 Jun 2008 10:07:38 +0900 |
User-agent: |
SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/23.0.60 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
In article <address@hidden>, Chong Yidong <address@hidden> 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
address@hidden