|
60 | 60 | #include "w32fd.h"
|
61 | 61 | #include "inc\string.h"
|
62 | 62 | #include "inc\time.h"
|
63 |
| -#include "..\..\..\atomicio.h" |
64 |
| -#include "urlmon.h" |
65 | 63 |
|
66 | 64 | #include <wchar.h>
|
67 | 65 |
|
@@ -137,9 +135,6 @@ int chroot_path_len = 0;
|
137 | 135 | /* UTF-16 version of the above */
|
138 | 136 | wchar_t* chroot_pathw = NULL;
|
139 | 137 |
|
140 |
| -/* motw zone_id initialized to invalid value */ |
141 |
| -DWORD motw_zone_id = 5; |
142 |
| - |
143 | 138 | int
|
144 | 139 | usleep(unsigned int useconds)
|
145 | 140 | {
|
@@ -2158,99 +2153,3 @@ strrstr(const char *inStr, const char *pattern)
|
2158 | 2153 | return last;
|
2159 | 2154 | }
|
2160 | 2155 |
|
2161 |
| -int |
2162 |
| -add_mark_of_web(const char* filename) |
2163 |
| -{ |
2164 |
| - if (motw_zone_id > 4) { |
2165 |
| - return -1; |
2166 |
| - } |
2167 |
| - char* fileStreamPath = NULL; |
2168 |
| - size_t fileStreamPathLen = strlen(filename) + strlen(":Zone.Identifier") + 1; |
2169 |
| - |
2170 |
| - fileStreamPath = malloc(fileStreamPathLen * sizeof(char)); |
2171 |
| - |
2172 |
| - if (fileStreamPath == NULL) { |
2173 |
| - return -1; |
2174 |
| - } |
2175 |
| - |
2176 |
| - sprintf_s(fileStreamPath, fileStreamPathLen, "%s:Zone.Identifier", filename); |
2177 |
| - |
2178 |
| - int ofd, status = 0; |
2179 |
| - char* zoneIdentifierStr = NULL; |
2180 |
| - size_t zoneIdentifierLen = strlen("[ZoneTransfer]\nZoneId=") + 1 + 1; |
2181 |
| - |
2182 |
| - zoneIdentifierStr = malloc(zoneIdentifierLen * sizeof(char)); |
2183 |
| - |
2184 |
| - if (zoneIdentifierStr == NULL) { |
2185 |
| - status = -1; |
2186 |
| - goto cleanup; |
2187 |
| - } |
2188 |
| - |
2189 |
| - sprintf_s(zoneIdentifierStr, zoneIdentifierLen, "[ZoneTransfer]\nZoneId=%d", motw_zone_id); |
2190 |
| - |
2191 |
| - // create zone identifer file stream and then write the Mark of the Web to it |
2192 |
| - if ((ofd = open(fileStreamPath, O_WRONLY | O_CREAT, USHRT_MAX)) == -1) { |
2193 |
| - status = -1; |
2194 |
| - goto cleanup; |
2195 |
| - } |
2196 |
| - |
2197 |
| - if (atomicio(vwrite, ofd, zoneIdentifierStr, zoneIdentifierLen) != zoneIdentifierLen) { |
2198 |
| - status = -1; |
2199 |
| - } |
2200 |
| - |
2201 |
| - if (close(ofd) == -1) { |
2202 |
| - status = -1; |
2203 |
| - } |
2204 |
| - |
2205 |
| -cleanup: |
2206 |
| - free(fileStreamPath); |
2207 |
| - if (zoneIdentifierStr) |
2208 |
| - free(zoneIdentifierStr); |
2209 |
| - return status; |
2210 |
| -} |
2211 |
| - |
2212 |
| -/* Gets the zone identifier value based on the provided hostname, |
2213 |
| -and sets the global motw_zone_id variable with that value. */ |
2214 |
| -void get_zone_identifier(const char* hostname) { |
2215 |
| - HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); |
2216 |
| - if (!SUCCEEDED(hr)) { |
2217 |
| - debug("CoInitializeEx for MapUrlToZone failed"); |
2218 |
| - return; |
2219 |
| - } |
2220 |
| - IInternetSecurityManager *pIISM = NULL; |
2221 |
| - // CLSID_InternetSecurityManager & IID_IInternetSecurityManager declared in urlmon.h |
2222 |
| - hr = CoCreateInstance(&CLSID_InternetSecurityManager, NULL, |
2223 |
| - CLSCTX_ALL, &IID_IInternetSecurityManager, (void**)&pIISM); |
2224 |
| - if (!SUCCEEDED(hr)) { |
2225 |
| - debug("CoCreateInstance for MapUrlToZone failed"); |
2226 |
| - goto out; |
2227 |
| - } |
2228 |
| - wchar_t *hostname_w = NULL, *hostformat_w = NULL; |
2229 |
| - hostname_w = utf8_to_utf16(hostname); |
2230 |
| - if (hostname_w == NULL) { |
2231 |
| - goto cleanup; |
2232 |
| - } |
2233 |
| - size_t hostname_w_len = wcslen(hostname_w) + wcslen(L"ftp://") + 1; |
2234 |
| - hostformat_w = malloc(hostname_w_len * sizeof(wchar_t)); |
2235 |
| - if (hostformat_w == NULL) { |
2236 |
| - goto cleanup; |
2237 |
| - } |
2238 |
| - swprintf_s(hostformat_w, hostname_w_len, L"ftp://%s", hostname_w); |
2239 |
| - hr = pIISM->lpVtbl->MapUrlToZone(pIISM, hostformat_w, &motw_zone_id, 0); |
2240 |
| - if (hr == S_OK) { |
2241 |
| - debug("MapUrlToZone zone identifier value: %d", motw_zone_id); |
2242 |
| - } |
2243 |
| - else { |
2244 |
| - motw_zone_id = 5; |
2245 |
| - debug("MapUrlToZone failed, resetting motw_zone_id to invalid value"); |
2246 |
| - } |
2247 |
| -cleanup: |
2248 |
| - if (pIISM) |
2249 |
| - pIISM->lpVtbl->Release(pIISM); |
2250 |
| - if (hostname_w) |
2251 |
| - free(hostname_w); |
2252 |
| - if (hostformat_w) |
2253 |
| - free(hostformat_w); |
2254 |
| -out: |
2255 |
| - CoUninitialize(); |
2256 |
| -} |
0 commit comments