diff options
author | Eric van Gyzen <vangyzen@FreeBSD.org> | 2018-11-02 22:10:07 +0000 |
---|---|---|
committer | Eric van Gyzen <vangyzen@FreeBSD.org> | 2018-11-02 22:10:07 +0000 |
commit | 77c85705a616126682be274fd54e9c4308083501 (patch) | |
tree | a02e6dd407e533d1d1cab88ead33a499d9291ae4 /xmlwf/unixfilemap.c | |
parent | 17c9c52d9a57f24fdf6202e339e7a713e97d27bb (diff) | |
download | src-77c85705a616126682be274fd54e9c4308083501.tar.gz src-77c85705a616126682be274fd54e9c4308083501.zip |
Vendor import of expat 2.2.6vendor/expat/2.2.6
Sponsored by: Dell EMC Isilon
Notes
Notes:
svn path=/vendor/expat/dist/; revision=340084
svn path=/vendor/expat/2.2.6/; revision=340085; tag=vendor/expat/2.2.6
Diffstat (limited to 'xmlwf/unixfilemap.c')
-rw-r--r--[-rwxr-xr-x] | xmlwf/unixfilemap.c | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/xmlwf/unixfilemap.c b/xmlwf/unixfilemap.c index e13299da05fc..4ab757c2ab9c 100755..100644 --- a/xmlwf/unixfilemap.c +++ b/xmlwf/unixfilemap.c @@ -1,5 +1,33 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. +/* + __ __ _ + ___\ \/ /_ __ __ _| |_ + / _ \\ /| '_ \ / _` | __| + | __// \| |_) | (_| | |_ + \___/_/\_\ .__/ \__,_|\__| + |_| XML parser + + Copyright (c) 1997-2000 Thai Open Source Software Center Ltd + Copyright (c) 2000-2017 Expat development team + Licensed under the MIT license: + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to permit + persons to whom the Software is furnished to do so, subject to the + following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <sys/types.h> @@ -15,11 +43,18 @@ #define MAP_FILE 0 #endif +#include "xmltchar.h" #include "filemap.h" +#ifdef XML_UNICODE_WCHAR_T +# define XML_FMT_STR "ls" +#else +# define XML_FMT_STR "s" +#endif + int -filemap(const char *name, - void (*processor)(const void *, size_t, const char *, void *arg), +filemap(const tchar *name, + void (*processor)(const void *, size_t, const tchar *, void *arg), void *arg) { int fd; @@ -27,21 +62,25 @@ filemap(const char *name, struct stat sb; void *p; - fd = open(name, O_RDONLY); + fd = topen(name, O_RDONLY); if (fd < 0) { - perror(name); + tperror(name); return 0; } if (fstat(fd, &sb) < 0) { - perror(name); + tperror(name); close(fd); return 0; } if (!S_ISREG(sb.st_mode)) { close(fd); - fprintf(stderr, "%s: not a regular file\n", name); + fprintf(stderr, "%" XML_FMT_STR ": not a regular file\n", name); return 0; } + if (sb.st_size > XML_MAX_CHUNK_LEN) { + close(fd); + return 2; /* Cannot be passed to XML_Parse in one go */ + } nbytes = sb.st_size; /* mmap fails for zero length files */ @@ -54,7 +93,7 @@ filemap(const char *name, p = (void *)mmap((void *)0, (size_t)nbytes, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, (off_t)0); if (p == (void *)-1) { - perror(name); + tperror(name); close(fd); return 0; } |