Ticket #231: cp_HPFS386.fiff

File cp_HPFS386.fiff, 7.4 KB (added by dmik, 14 years ago)
Line 
1Index: fs.c
2===================================================================
3--- fs.c (revision 3657)
4+++ fs.c (working copy)
5@@ -336,14 +336,14 @@
6 /*
7 * Setup the the executable path rewrite rule.
8 */
9- PTIB pTib;
10+ PTIB pTib;
11 PPIB pPib;
12 DosGetInfoBlocks(&pTib, &pPib);
13 rc = DosQueryModuleName(pPib->pib_hmte, sizeof(__libc_gszExecPath), &__libc_gszExecPath[0]);
14- if (!rc)
15+ if (!rc)
16 {
17 char *psz = strchr(&__libc_gszExecPath[0], '\0');
18- while ( psz > &__libc_gszExecPath[0]
19+ while ( psz > &__libc_gszExecPath[0]
20 && *psz != '\\'
21 && *psz != '/'
22 && *psz != ':')
23@@ -364,7 +364,7 @@
24 ULONG ulBootDrive;
25 if (DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, sizeof(ulBootDrive)))
26 ulBootDrive = 'C' - 'A' - 1; /* A = 1 */
27- __libc_gszTmpDir[0] = __libc_gszSystemRoot[0] = __libc_gszSystemDrive[0]
28+ __libc_gszTmpDir[0] = __libc_gszSystemRoot[0] = __libc_gszSystemDrive[0]
29 = (char)ulBootDrive + 'A' - 1;
30
31 /*
32@@ -1567,72 +1567,73 @@
33 rc = -__libc_native2errno(rc);
34 LIBCLOG_ERROR_RETURN_INT(rc);
35 }
36- if (pEaOp2->fpFEA2List->cbList < LIBC_UNIX_EA_MIN)
37- LIBCLOG_RETURN_INT(0);
38
39 /*
40- * Parse the result.
41+ * Parse the result (unless there's none of the requested EAs returned at all).
42 */
43- PFEA2 pFea2 = &pEaOp2->fpFEA2List->list[0];
44- for (;;)
45+ if (pEaOp2->fpFEA2List->cbList > sizeof(FEA2))
46 {
47- if (pFea2->cbValue > 0)
48+ PFEA2 pFea2 = &pEaOp2->fpFEA2List->list[0];
49+ for (;;)
50 {
51+ if (pFea2->cbValue > 0)
52+ {
53 #define COMPARE_EANAME(name) (pFea2->cbName == sizeof(name) - 1 && !memcmp(name, pFea2->szName, sizeof(name) - 1))
54- if (COMPARE_EANAME(__libc_gszSymlinkEA))
55- pStat->st_mode = (pStat->st_mode & ~S_IFMT) | S_IFLNK;
56- else
57- {
58- PUSHORT pusType = (PUSHORT)&pFea2->szName[pFea2->cbName + 1];
59- if (*pusType == EAT_BINARY)
60+ if (COMPARE_EANAME(__libc_gszSymlinkEA))
61+ pStat->st_mode = (pStat->st_mode & ~S_IFMT) | S_IFLNK;
62+ else
63 {
64- pusType++;
65- if (*pusType == sizeof(uint32_t))
66+ PUSHORT pusType = (PUSHORT)&pFea2->szName[pFea2->cbName + 1];
67+ if (*pusType == EAT_BINARY)
68 {
69- uint32_t u32 = *(uint32_t *)++pusType;
70- if (COMPARE_EANAME(__libc_gszUidEA))
71- pStat->st_uid = u32;
72- else if (COMPARE_EANAME(__libc_gszGidEA))
73- pStat->st_gid = u32;
74- else if (COMPARE_EANAME(__libc_gszModeEA))
75+ pusType++;
76+ if (*pusType == sizeof(uint32_t))
77 {
78- if ( S_ISDIR(u32) || S_ISCHR(u32) || S_ISBLK(u32) || S_ISREG(u32)
79- || S_ISFIFO(u32) || S_ISLNK(u32) || S_ISSOCK(u32) || S_ISWHT(u32))
80- pStat->st_mode = u32;
81+ uint32_t u32 = *(uint32_t *)++pusType;
82+ if (COMPARE_EANAME(__libc_gszUidEA))
83+ pStat->st_uid = u32;
84+ else if (COMPARE_EANAME(__libc_gszGidEA))
85+ pStat->st_gid = u32;
86+ else if (COMPARE_EANAME(__libc_gszModeEA))
87+ {
88+ if ( S_ISDIR(u32) || S_ISCHR(u32) || S_ISBLK(u32) || S_ISREG(u32)
89+ || S_ISFIFO(u32) || S_ISLNK(u32) || S_ISSOCK(u32) || S_ISWHT(u32))
90+ pStat->st_mode = u32;
91+ else
92+ LIBC_ASSERTM_FAILED("Invalid file mode EA: u32=0%o (st_mode=0%o)\n", u32, pStat->st_mode);
93+ }
94+ else if (COMPARE_EANAME(__libc_gszRDevEA))
95+ pStat->st_rdev = u32;
96+ else if (COMPARE_EANAME(__libc_gszGenEA))
97+ pStat->st_gen = u32;
98+ else if (COMPARE_EANAME(__libc_gszFlagsEA))
99+ pStat->st_flags = u32;
100 else
101- LIBC_ASSERTM_FAILED("Invalid file mode EA: u32=0%o (st_mode=0%o)\n", u32, pStat->st_mode);
102+ LIBC_ASSERTM_FAILED("Huh?!? got an ea named '%s', namelen=%d! u32=%#x (%d)\n", pFea2->szName, pFea2->cbName, u32, u32);
103 }
104- else if (COMPARE_EANAME(__libc_gszRDevEA))
105- pStat->st_rdev = u32;
106- else if (COMPARE_EANAME(__libc_gszGenEA))
107- pStat->st_gen = u32;
108- else if (COMPARE_EANAME(__libc_gszFlagsEA))
109- pStat->st_flags = u32;
110+ else if (*pusType == sizeof(uint64_t))
111+ {
112+ uint64_t u64 = *(uint64_t *)++pusType;
113+ if (COMPARE_EANAME(__libc_gszInoEA))
114+ pStat->st_ino = u64;
115+ else
116+ LIBC_ASSERTM_FAILED("Huh?!? got an ea named '%s', namelen=%d! u64=%#llx (%lld)\n", pFea2->szName, pFea2->cbName, u64, u64);
117+ }
118 else
119- LIBC_ASSERTM_FAILED("Huh?!? got an ea named '%s', namelen=%d! u32=%#x (%d)\n", pFea2->szName, pFea2->cbName, u32, u32);
120+ LIBC_ASSERTM_FAILED("Invalid LIBC EA! '%s' len=%#x and len=4 or 8.\n", pFea2->szName, *pusType);
121 }
122- else if (*pusType == sizeof(uint64_t))
123- {
124- uint64_t u64 = *(uint64_t *)++pusType;
125- if (COMPARE_EANAME(__libc_gszInoEA))
126- pStat->st_ino = u64;
127- else
128- LIBC_ASSERTM_FAILED("Huh?!? got an ea named '%s', namelen=%d! u64=%#llx (%lld)\n", pFea2->szName, pFea2->cbName, u64, u64);
129- }
130 else
131- LIBC_ASSERTM_FAILED("Invalid LIBC EA! '%s' len=%#x and len=4 or 8.\n", pFea2->szName, *pusType);
132+ LIBC_ASSERTM_FAILED("Invalid LIBC EA! '%s' type=%#x len=%#x, expected type=%#x and len=4 or 8.\n",
133+ pFea2->szName, pusType[0], pusType[1], EAT_BINARY);
134 }
135- else
136- LIBC_ASSERTM_FAILED("Invalid LIBC EA! '%s' type=%#x len=%#x, expected type=%#x and len=4 or 8.\n",
137- pFea2->szName, pusType[0], pusType[1], EAT_BINARY);
138+#undef COMPARE_EANAME
139 }
140-#undef COMPARE_EANAME
141+
142+ /* next */
143+ if (pFea2->oNextEntryOffset <= sizeof(FEA2))
144+ break;
145+ pFea2 = (PFEA2)((uintptr_t)pFea2 + pFea2->oNextEntryOffset);
146 }
147-
148- /* next */
149- if (pFea2->oNextEntryOffset <= sizeof(FEA2))
150- break;
151- pFea2 = (PFEA2)((uintptr_t)pFea2 + pFea2->oNextEntryOffset);
152 }
153
154 /*