| OLD | NEW |
| 1 /* | 1 /* |
| 2 * security.c: Implementation of the XSLT security framework | 2 * security.c: Implementation of the XSLT security framework |
| 3 * | 3 * |
| 4 * See Copyright for the status of this software. | 4 * See Copyright for the status of this software. |
| 5 * | 5 * |
| 6 * daniel@veillard.com | 6 * daniel@veillard.com |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #define IN_LIBXSLT | 9 #define IN_LIBXSLT |
| 10 #include "libxslt.h" | 10 #include "libxslt.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 | 175 |
| 176 /** | 176 /** |
| 177 * xsltSetDefaultSecurityPrefs: | 177 * xsltSetDefaultSecurityPrefs: |
| 178 * @sec: the security block to use | 178 * @sec: the security block to use |
| 179 * | 179 * |
| 180 * Set the default security preference application-wide | 180 * Set the default security preference application-wide |
| 181 */ | 181 */ |
| 182 void | 182 void |
| 183 xsltSetDefaultSecurityPrefs(xsltSecurityPrefsPtr sec) { | 183 xsltSetDefaultSecurityPrefs(xsltSecurityPrefsPtr sec) { |
| 184 | 184 |
| 185 xsltDefaultSecurityPrefs = sec; | 185 xsltDefaultSecurityPrefs = sec; |
| 186 } | 186 } |
| 187 | 187 |
| 188 /** | 188 /** |
| 189 * xsltGetDefaultSecurityPrefs: | 189 * xsltGetDefaultSecurityPrefs: |
| 190 * | 190 * |
| 191 * Get the default security preference application-wide | 191 * Get the default security preference application-wide |
| 192 * | 192 * |
| 193 * Returns the current xsltSecurityPrefsPtr in use or NULL if none | 193 * Returns the current xsltSecurityPrefsPtr in use or NULL if none |
| 194 */ | 194 */ |
| 195 xsltSecurityPrefsPtr | 195 xsltSecurityPrefsPtr |
| 196 xsltGetDefaultSecurityPrefs(void) { | 196 xsltGetDefaultSecurityPrefs(void) { |
| 197 return(xsltDefaultSecurityPrefs); | 197 return(xsltDefaultSecurityPrefs); |
| 198 } | 198 } |
| 199 | 199 |
| 200 /** | 200 /** |
| 201 * xsltSetCtxtSecurityPrefs: | 201 * xsltSetCtxtSecurityPrefs: |
| 202 * @sec: the security block to use | 202 * @sec: the security block to use |
| 203 * @ctxt: an XSLT transformation context | 203 * @ctxt: an XSLT transformation context |
| 204 * | 204 * |
| 205 * Set the security preference for a specific transformation | 205 * Set the security preference for a specific transformation |
| 206 * | 206 * |
| 207 * Returns -1 in case of error, 0 otherwise | 207 * Returns -1 in case of error, 0 otherwise |
| 208 */ | 208 */ |
| 209 int | 209 int |
| 210 xsltSetCtxtSecurityPrefs(xsltSecurityPrefsPtr sec, | 210 xsltSetCtxtSecurityPrefs(xsltSecurityPrefsPtr sec, |
| 211 xsltTransformContextPtr ctxt) { | 211 xsltTransformContextPtr ctxt) { |
| 212 if (ctxt == NULL) | 212 if (ctxt == NULL) |
| 213 return(-1); | 213 return(-1); |
| 214 ctxt->sec = (void *) sec; | 214 ctxt->sec = (void *) sec; |
| 215 return(0); | 215 return(0); |
| 216 } | 216 } |
| 217 | 217 |
| 218 | 218 |
| 219 /** | 219 /** |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 258 |
| 259 /** | 259 /** |
| 260 * xsltCheckFilename | 260 * xsltCheckFilename |
| 261 * @path: the path to check | 261 * @path: the path to check |
| 262 * | 262 * |
| 263 * function checks to see if @path is a valid source | 263 * function checks to see if @path is a valid source |
| 264 * (file, socket...) for XML. | 264 * (file, socket...) for XML. |
| 265 * | 265 * |
| 266 * TODO: remove at some point !!! | 266 * TODO: remove at some point !!! |
| 267 * Local copy of xmlCheckFilename to avoid a hard dependency on | 267 * Local copy of xmlCheckFilename to avoid a hard dependency on |
| 268 * a new version of libxml2 | 268 * a new version of libxml2 |
| 269 * | 269 * |
| 270 * if stat is not available on the target machine, | 270 * if stat is not available on the target machine, |
| 271 * returns 1. if stat fails, returns 0 (if calling | 271 * returns 1. if stat fails, returns 0 (if calling |
| 272 * stat on the filename fails, it can't be right). | 272 * stat on the filename fails, it can't be right). |
| 273 * if stat succeeds and the file is a directory, | 273 * if stat succeeds and the file is a directory, |
| 274 * returns 2. otherwise returns 1. | 274 * returns 2. otherwise returns 1. |
| 275 */ | 275 */ |
| 276 | 276 |
| 277 static int | 277 static int |
| 278 xsltCheckFilename (const char *path) | 278 xsltCheckFilename (const char *path) |
| 279 { | 279 { |
| 280 #ifdef HAVE_STAT | 280 #ifdef HAVE_STAT |
| 281 struct stat stat_buffer; | 281 struct stat stat_buffer; |
| 282 #if defined(WIN32) && !defined(__CYGWIN__) | 282 #if defined(WIN32) && !defined(__CYGWIN__) |
| 283 DWORD dwAttrs; | 283 DWORD dwAttrs; |
| 284 | 284 |
| 285 dwAttrs = GetFileAttributesA(path); | 285 dwAttrs = GetFileAttributesA(path); |
| 286 if (dwAttrs != INVALID_FILE_ATTRIBUTES) { | 286 if (dwAttrs != INVALID_FILE_ATTRIBUTES) { |
| 287 if (dwAttrs & FILE_ATTRIBUTE_DIRECTORY) { | 287 if (dwAttrs & FILE_ATTRIBUTE_DIRECTORY) { |
| 288 return 2; | 288 return 2; |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 #endif | 291 #endif |
| 292 | 292 |
| 293 if (stat(path, &stat_buffer) == -1) | 293 if (stat(path, &stat_buffer) == -1) |
| 294 return 0; | 294 return 0; |
| 295 | 295 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 "Network file read for %s refused\n", URL); | 471 "Network file read for %s refused\n", URL); |
| 472 xmlFreeURI(uri); | 472 xmlFreeURI(uri); |
| 473 return(0); | 473 return(0); |
| 474 } | 474 } |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 xmlFreeURI(uri); | 477 xmlFreeURI(uri); |
| 478 return(1); | 478 return(1); |
| 479 } | 479 } |
| 480 | 480 |
| OLD | NEW |