Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/cd9660 change wget_utf8() to not require NUL-terminat...



details:   https://anonhg.NetBSD.org/src/rev/fbbf4d537abc
branches:  trunk
changeset: 572257:fbbf4d537abc
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Mon Dec 27 18:47:16 2004 +0000

description:
change wget_utf8() to not require NUL-terminated string as input,
and adjust callers appropriately. cn_nameptr isn't NUL-terminated
for non-leaf components, so it's incorrect to assume it is always
NUL-terminated.

This fixes previous utf8-ization changes to not panic for cases
like 'echo */*/*.ps' in case the intermediate path components
are not in cache (yet).

diffstat:

 sys/fs/cd9660/cd9660_util.c |  15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diffs (54 lines):

diff -r e40fc4c5a47b -r fbbf4d537abc sys/fs/cd9660/cd9660_util.c
--- a/sys/fs/cd9660/cd9660_util.c       Mon Dec 27 18:14:36 2004 +0000
+++ b/sys/fs/cd9660/cd9660_util.c       Mon Dec 27 18:47:16 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_util.c,v 1.3 2004/11/21 21:49:08 jdolecek Exp $ */
+/*     $NetBSD: cd9660_util.c,v 1.4 2004/12/27 18:47:16 jdolecek Exp $ */
 
 /*-
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_util.c,v 1.3 2004/11/21 21:49:08 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_util.c,v 1.4 2004/12/27 18:47:16 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -58,7 +58,7 @@
 
 #include <fs/unicode.h>
 
-static u_int16_t wget(const u_char **, int);
+static u_int16_t wget(const u_char **, size_t *, int);
 static int wput(u_char *, size_t, u_int16_t, int);
 
 int cd9660_utf8_joliet = 1;
@@ -106,10 +106,9 @@
        u_int16_t fc, ic;
        const u_char *isoend = isofn + isolen;
 
-       /* fn should always contain standard C string, and wget() needs it */
-       KASSERT(fn[fnlen] == 0);
+       while (fnlen > 0) {
+               fc = wget(&fn, &fnlen, joliet_level);
 
-       while ((fc = wget(&fn, joliet_level)) && fc) {
                if (isofn == isoend)
                        return fc;
                isofn += isochar(isofn, isoend, joliet_level, &ic);
@@ -213,11 +212,11 @@
 }
 
 static u_int16_t
-wget(const u_char **str, int joliet_level)
+wget(const u_char **str, size_t *sz, int joliet_level)
 {
        if (joliet_level > 0 && cd9660_utf8_joliet) {
                /* decode UTF-8 sequence */
-               return wget_utf8((const char **) str);
+               return wget_utf8((const char **) str, sz);
        } else {
                /*
                 * Raw 8-bit characters without any conversion. For Joliet,



Home | Main Index | Thread Index | Old Index