]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/isofs/cd9660/cd9660_util.c
xnu-792.18.15.tar.gz
[apple/xnu.git] / bsd / isofs / cd9660 / cd9660_util.c
index 0a3b9315bbe53b7da2ce7df23070aca6c20c05a1..6abbc84bf70b7871fc0ac9d7efebc764a5f80297 100644 (file)
@@ -91,7 +91,6 @@
 #include <sys/dir.h>
 #include <sys/attr.h>
 #include <kern/assert.h>
-#include <architecture/byte_order.h>
 
 #include <isofs/cd9660/iso.h>
 #include <isofs/cd9660/cd9660_node.h>
@@ -162,6 +161,10 @@ isofncmp(u_char *fn, int fnlen, u_char *isofn, int isolen)
 /*
  * translate and compare a UCS-2 filename
  * Note: Version number plus ';' may be omitted.
+ *
+ * The name pointed to by "fn" is the search name, whose characters are
+ * in native endian order.  The name "ucsfn" is the on-disk name, whose
+ * characters are in big endian order.
  */
 
 int
@@ -177,7 +180,7 @@ ucsfncmp(u_int16_t *fn, int fnlen, u_int16_t *ucsfn, int ucslen)
        while (--fnlen >= 0) {
                if (--ucslen < 0)
                        return *fn;
-               if ((c = *ucsfn++) == UCS_SEPARATOR2) {
+               if ((c = OSSwapBigToHostInt16(*ucsfn++)) == UCS_SEPARATOR2) {
                        switch (*fn++) {
                        default:
                                return *--fn;
@@ -191,7 +194,7 @@ ucsfncmp(u_int16_t *fn, int fnlen, u_int16_t *ucsfn, int ucslen)
                                        return -1;
                                }
                        }
-                       for (j = 0; --ucslen >= 0; j = j * 10 + *ucsfn++ - '0');
+                       for (j = 0; --ucslen >= 0; j = j * 10 + OSSwapBigToHostInt16(*ucsfn++) - '0');
                        return i - j;
                }
                if (c != *fn)
@@ -202,10 +205,10 @@ ucsfncmp(u_int16_t *fn, int fnlen, u_int16_t *ucsfn, int ucslen)
                switch (*ucsfn) {
                default:
                        return -1;
-               case UCS_SEPARATOR1:
-                       if (ucsfn[1] != UCS_SEPARATOR2)
+               case OSSwapHostToBigConstInt16(UCS_SEPARATOR1):
+                       if (ucsfn[1] != OSSwapHostToBigConstInt16(UCS_SEPARATOR2))
                                return -1;
-               case UCS_SEPARATOR2:
+               case OSSwapHostToBigConstInt16(UCS_SEPARATOR2):
                        return 0;
                }
        }
@@ -292,9 +295,9 @@ ucsfntrans(u_int16_t *infn, int infnlen, u_char *outfn, u_short *outfnlen,
                        /* strip file version number */
                        for (fnidx--; fnidx > 0; fnidx--) {
                                /* stop when ';' is found */
-                               if (infn[fnidx] == UCS_SEPARATOR2) {
+                               if (infn[fnidx] == OSSwapHostToBigConstInt16(UCS_SEPARATOR2)) {
                                        /* drop dangling dot */
-                                       if (fnidx > 0 && infn[fnidx-1] == UCS_SEPARATOR1)
+                                       if (fnidx > 0 && infn[fnidx-1] == OSSwapHostToBigConstInt16(UCS_SEPARATOR1))
                                                fnidx--;
                                        break;
                                }