mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
fix
This commit is contained in:
parent
b6d38a2f05
commit
639362309f
|
@ -570,10 +570,10 @@ static inline bool u_is_overlap(const char* restrict dst, const char* restrict s
|
|||
|
||||
static inline __pure const char* u_basename(const char* restrict path, uint32_t len)
|
||||
{
|
||||
U_INTERNAL_TRACE("u_basename(%.*s,%u)", U_min(len,128), path, len)
|
||||
|
||||
const char* restrict ptr;
|
||||
|
||||
U_INTERNAL_TRACE("u_basename(%.*s,%u)", U_min(len,128), path, len)
|
||||
|
||||
U_INTERNAL_ASSERT_MAJOR(len, 0)
|
||||
U_INTERNAL_ASSERT_POINTER(path)
|
||||
|
||||
|
@ -583,7 +583,7 @@ static inline __pure const char* u_basename(const char* restrict path, uint32_t
|
|||
* for (ptr = path+len-2; ptr > path; --ptr) if (IS_DIR_SEPARATOR(*ptr)) return ptr+1;
|
||||
*/
|
||||
|
||||
ptr = (const char* restrict) memrchr(path, '/', len);
|
||||
ptr = (const char* restrict) memrchr(path, PATH_SEPARATOR, len);
|
||||
|
||||
return (ptr ? ptr+1 : path);
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ static inline const char* u_getsuffix(const char* restrict path, uint32_t len)
|
|||
* return (ptr && memrchr(ptr+1, '/', len-(ptr+1-path)) == 0 ? ptr : 0);
|
||||
*/
|
||||
|
||||
for (ptr = path+len-2; ptr > path; --ptr)
|
||||
for (ptr = path+len-2; ptr >= path; --ptr)
|
||||
{
|
||||
c = *ptr;
|
||||
|
||||
|
|
|
@ -221,12 +221,15 @@ U_EXPORT bool u_validate_email_address(const char* restrict address, uint32_t ad
|
|||
|
||||
static inline bool u_isSuffixSwap(const char* restrict suffix) // NB: vi tmp...
|
||||
{
|
||||
U_INTERNAL_TRACE("u_isSuffixSwap(%s)", suffix)
|
||||
U_INTERNAL_TRACE("u_isSuffixSwap(%p)", suffix)
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(suffix[0], '.')
|
||||
U_INTERNAL_ASSERT_EQUALS(strchr(suffix, '/'), U_NULLPTR)
|
||||
if (suffix)
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(suffix[0], '.')
|
||||
U_INTERNAL_ASSERT_EQUALS(strchr(suffix, '/'), U_NULLPTR)
|
||||
|
||||
if (u_get_unalignedp32(suffix) == U_MULTICHAR_CONSTANT32('.','s','w','p')) return true;
|
||||
if (u_get_unalignedp32(suffix) == U_MULTICHAR_CONSTANT32('.','s','w','p')) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -132,7 +132,14 @@ public:
|
|||
// PATH
|
||||
|
||||
void setRoot();
|
||||
void setPath(const UString& path, const UString* environment = U_NULLPTR);
|
||||
void setPath(const UString& path, const UString* environment = U_NULLPTR)
|
||||
{
|
||||
U_TRACE(0, "UFile::setPath(%V,%p)", path.rep, environment)
|
||||
|
||||
pathname = path;
|
||||
|
||||
setPathRelativ(environment);
|
||||
}
|
||||
|
||||
bool isRoot() const
|
||||
{
|
||||
|
@ -173,31 +180,12 @@ public:
|
|||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool isSuffixSwap() const // NB: vi tmp...
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "UFile::isSuffixSwap()")
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
const char* suffix = u_getsuffix(path_relativ, path_relativ_len);
|
||||
|
||||
if (suffix &&
|
||||
u_isSuffixSwap(suffix))
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
// NB: the string can be not writable so path_relativ[path_relativ_len] can be != '\0'...
|
||||
|
||||
UString& getPath() { return pathname; }
|
||||
UString getName() const;
|
||||
UString getDirName() const;
|
||||
UString getSuffix() const;
|
||||
UString& getPath() { return pathname; }
|
||||
UString getSuffix() const { return getSuffix(u_getsuffix(path_relativ, path_relativ_len)); }
|
||||
char* getPathRelativ() const { return (char*)path_relativ; }
|
||||
int32_t getPathRelativLen() const { return path_relativ_len; }
|
||||
|
||||
|
@ -251,7 +239,14 @@ public:
|
|||
}
|
||||
|
||||
bool creat( int flags = O_TRUNC | O_RDWR, mode_t mode = PERM_FILE);
|
||||
bool creat(const UString& path, int flags = O_TRUNC | O_RDWR, mode_t mode = PERM_FILE);
|
||||
bool creat(const UString& path, int flags = O_TRUNC | O_RDWR, mode_t mode = PERM_FILE)
|
||||
{
|
||||
U_TRACE(0, "UFile::creat(%V,%d,%d)", path.rep, flags, mode)
|
||||
|
||||
setPath(path);
|
||||
|
||||
return creat(flags, mode);
|
||||
}
|
||||
|
||||
void reopen(int flags)
|
||||
{
|
||||
|
@ -259,10 +254,10 @@ public:
|
|||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
close();
|
||||
|
||||
U_INTERNAL_ASSERT(pathname.isNullTerminated())
|
||||
|
@ -318,10 +313,10 @@ public:
|
|||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
if (U_SYSCALL(access, "%S,%d", U_PATH_CONV(path_relativ), mode) == 0) U_RETURN(true);
|
||||
|
||||
U_RETURN(false);
|
||||
|
@ -349,10 +344,10 @@ public:
|
|||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
if (U_SYSCALL(lstat, "%S,%p", U_PATH_CONV(path_relativ), (struct stat*)this) == 0) U_RETURN(true);
|
||||
|
||||
U_RETURN(false);
|
||||
|
@ -368,9 +363,9 @@ public:
|
|||
U_INTERNAL_ASSERT_DIFFERS(fd, -1)
|
||||
|
||||
# if defined(DEBUG) && !defined(U_LINUX) && !defined(O_TMPFILE)
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
# endif
|
||||
|
||||
# ifdef U_COVERITY_FALSE_POSITIVE
|
||||
|
@ -404,9 +399,9 @@ public:
|
|||
U_INTERNAL_ASSERT_DIFFERS(fd, -1)
|
||||
|
||||
# if defined(DEBUG) && !defined(U_LINUX) && !defined(O_TMPFILE)
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
# endif
|
||||
|
||||
st_size = lseek(U_SEEK_BEGIN, SEEK_END);
|
||||
|
@ -604,10 +599,10 @@ public:
|
|||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
if (UFile::_unlink(path_relativ)) U_RETURN(true);
|
||||
|
||||
U_RETURN(false);
|
||||
|
@ -634,9 +629,9 @@ public:
|
|||
U_INTERNAL_ASSERT_DIFFERS(fd, -1)
|
||||
|
||||
# if defined(DEBUG) && !defined(U_LINUX) && !defined(O_TMPFILE)
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
# endif
|
||||
|
||||
# ifdef U_COVERITY_FALSE_POSITIVE
|
||||
|
@ -654,9 +649,9 @@ public:
|
|||
U_INTERNAL_ASSERT_DIFFERS(fd, -1)
|
||||
|
||||
# if defined(DEBUG) && !defined(U_LINUX) && !defined(O_TMPFILE)
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
# endif
|
||||
|
||||
if (fallocate(fd, n))
|
||||
|
@ -685,9 +680,9 @@ public:
|
|||
U_INTERNAL_ASSERT_DIFFERS(fd, -1)
|
||||
|
||||
# if defined(DEBUG) && !defined(U_LINUX) && !defined(O_TMPFILE)
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
# endif
|
||||
|
||||
return lock(fd, l_type, start, len);
|
||||
|
@ -702,9 +697,9 @@ public:
|
|||
U_INTERNAL_ASSERT_DIFFERS(fd, -1)
|
||||
|
||||
# if defined(DEBUG) && !defined(U_LINUX) && !defined(O_TMPFILE)
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
# endif
|
||||
|
||||
return lock(fd, F_UNLCK, start, len);
|
||||
|
@ -841,9 +836,9 @@ public:
|
|||
U_INTERNAL_ASSERT_DIFFERS(fd, -1)
|
||||
|
||||
# if defined(DEBUG) && !defined(U_LINUX) && !defined(O_TMPFILE)
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
# endif
|
||||
|
||||
# ifdef U_COVERITY_FALSE_POSITIVE
|
||||
|
@ -1084,6 +1079,29 @@ protected:
|
|||
void setPathRelativ(const UString* environment = U_NULLPTR);
|
||||
void setPath(const UFile& file, char* buffer_path, const char* suffix, uint32_t len);
|
||||
|
||||
UString getSuffix(const char* ptr) const
|
||||
{
|
||||
U_TRACE(0, "UFile::getSuffix(%p)", ptr)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(ptr[0], '.')
|
||||
U_INTERNAL_ASSERT_EQUALS(strchr(ptr, '/'), U_NULLPTR)
|
||||
|
||||
ptr += 1; // 1 => '.'
|
||||
|
||||
UString suffix(ptr, (path_relativ + path_relativ_len) - ptr);
|
||||
|
||||
U_RETURN_STRING(suffix);
|
||||
}
|
||||
|
||||
return UString::getStringNull();
|
||||
}
|
||||
|
||||
static void ftw_tree_up();
|
||||
static void ftw_tree_push();
|
||||
static void ftw_vector_push();
|
||||
|
|
|
@ -333,7 +333,7 @@ public:
|
|||
static UString* rbuffer;
|
||||
static UString* wbuffer;
|
||||
static UString* request;
|
||||
static bool bIPv6, bsendGzipBomp;
|
||||
static bool bIPv6, bsendGzipBomb;
|
||||
|
||||
static char cbuffer[128];
|
||||
static UString* request_uri;
|
||||
|
|
|
@ -182,8 +182,6 @@ public:
|
|||
static UHashMap<UString>* prequestHeader;
|
||||
static UVector<UModProxyService*>* vservice;
|
||||
|
||||
static const char* uri_suffix;
|
||||
static const char* uri_basename;
|
||||
static char response_buffer[64];
|
||||
static int mime_index, cgi_timeout; // the time-out value in seconds for output cgi process
|
||||
static bool enable_caching_by_proxy_servers, skip_check_cookie_ip_address;
|
||||
|
@ -892,6 +890,7 @@ public:
|
|||
static void callSigHUPForAllUSP();
|
||||
static void callAfterForkForAllUSP();
|
||||
|
||||
static bool checkForUSP();
|
||||
static UServletPage* getUSP(const char* key, uint32_t key_len);
|
||||
|
||||
// CSP (C Servlet Page)
|
||||
|
@ -1302,7 +1301,7 @@ private:
|
|||
U_INTERNAL_ASSERT_POINTER(file)
|
||||
U_ASSERT_EQUALS(UClientImage_Base::isRequestNotFound(), false)
|
||||
|
||||
uri_suffix = u_getsuffix(U_FILE_TO_PARAM(*file));
|
||||
const char* uri_suffix = u_getsuffix(U_FILE_TO_PARAM(*file));
|
||||
|
||||
U_INTERNAL_DUMP("uri_suffix = %p", uri_suffix)
|
||||
|
||||
|
@ -1406,7 +1405,6 @@ private:
|
|||
static void setCGIShellScript(UString& command) U_NO_EXPORT;
|
||||
static bool checkIfSourceHasChangedAndCompileUSP() U_NO_EXPORT;
|
||||
static bool compileUSP(const char* path, uint32_t len) U_NO_EXPORT;
|
||||
static void manageDataForCache(const UString& file_name) U_NO_EXPORT;
|
||||
static int checkGetRequestForRange(const UString& data) U_NO_EXPORT;
|
||||
static int sortRange(const void* a, const void* b) __pure U_NO_EXPORT;
|
||||
static bool addHTTPVariables(UStringRep* key, void* value) U_NO_EXPORT;
|
||||
|
@ -1414,6 +1412,7 @@ private:
|
|||
static void putDataInCache(const UString& fmt, UString& content) U_NO_EXPORT;
|
||||
static bool readDataChunked(USocket* sk, UString* pbuffer, UString& body) U_NO_EXPORT;
|
||||
static void setResponseForRange(uint32_t start, uint32_t end, uint32_t header) U_NO_EXPORT;
|
||||
static void manageDataForCache(const UString& basename, const UString& suffix) U_NO_EXPORT;
|
||||
static bool checkDataSession(const UString& token, time_t expire, UString* data) U_NO_EXPORT;
|
||||
|
||||
static inline void resetFileCache() U_NO_EXPORT;
|
||||
|
|
|
@ -1887,13 +1887,15 @@ case_float:
|
|||
{
|
||||
double dbl = VA_ARG(double);
|
||||
|
||||
len = u_dtoa(dbl, bp) - bp;
|
||||
U_INTERNAL_PRINT("dbl = %g", dbl)
|
||||
|
||||
len = (dbl == .0 ? (*bp='0',1) : u_dtoa(dbl, bp) - bp);
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[0] = '%';
|
||||
|
||||
cp = buf + 1;
|
||||
cp = buf+1;
|
||||
|
||||
if ((flags & ALT) != 0) *cp++ = '#';
|
||||
if ((flags & ZEROPAD) != 0) *cp++ = '0';
|
||||
|
@ -1901,21 +1903,108 @@ case_float:
|
|||
if ((flags & THOUSANDS_GROUPED) != 0) *cp++ = '\'';
|
||||
if (sign) *cp++ = sign;
|
||||
|
||||
u_put_unalignedp32(cp, U_MULTICHAR_CONSTANT32('*','.','*','L')); /* width, prec */
|
||||
|
||||
u_put_unalignedp16(cp + ((flags & LONGDBL) == 0 ? 3 : 4), U_MULTICHAR_CONSTANT16(ch,'\0'));
|
||||
|
||||
if ((flags & LONGDBL) != 0)
|
||||
if (prec == -1 &&
|
||||
width == 0)
|
||||
{
|
||||
long double ldbl = VA_ARG(long double);
|
||||
u_put_unalignedp16(cp, U_MULTICHAR_CONSTANT16(ch,'\0'));
|
||||
|
||||
len = sprintf(bp, (const char* restrict)buf, width, prec, ldbl);
|
||||
if ((flags & LONGDBL) != 0)
|
||||
{
|
||||
long double ldbl = VA_ARG(long double);
|
||||
|
||||
U_INTERNAL_PRINT("buf = %s ldbl = %Lg", buf, ldbl)
|
||||
|
||||
len = sprintf(bp, (const char* restrict)buf, ldbl);
|
||||
}
|
||||
else
|
||||
{
|
||||
double dbl = VA_ARG(double);
|
||||
|
||||
U_INTERNAL_PRINT("buf = %s dbl = %g", buf, dbl)
|
||||
|
||||
len = sprintf(bp, (const char* restrict)buf, dbl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double dbl = VA_ARG(double);
|
||||
if (width == 0)
|
||||
{
|
||||
u_put_unalignedp32(cp, U_MULTICHAR_CONSTANT32('.','*','L','\0')); /* prec, prefix long double */
|
||||
|
||||
len = sprintf(bp, (const char* restrict)buf, width, prec, dbl);
|
||||
if ((flags & LONGDBL) != 0)
|
||||
{
|
||||
long double ldbl = VA_ARG(long double);
|
||||
|
||||
u_put_unalignedp16(cp+3, U_MULTICHAR_CONSTANT16(ch,'\0'));
|
||||
|
||||
U_INTERNAL_PRINT("buf = %s prec = %d ldbl = %Lg", buf, prec, ldbl)
|
||||
|
||||
len = sprintf(bp, (const char* restrict)buf, prec, ldbl);
|
||||
}
|
||||
else
|
||||
{
|
||||
double dbl = VA_ARG(double);
|
||||
|
||||
u_put_unalignedp16(cp+2, U_MULTICHAR_CONSTANT16(ch,'\0'));
|
||||
|
||||
U_INTERNAL_PRINT("buf = %s prec = %d dbl = %g", buf, prec, dbl)
|
||||
|
||||
len = sprintf(bp, (const char* restrict)buf, prec, dbl);
|
||||
}
|
||||
}
|
||||
else if (prec == -1)
|
||||
{
|
||||
u_put_unalignedp16(cp, U_MULTICHAR_CONSTANT16('*','L')); /* width, prefix long double */
|
||||
|
||||
if ((flags & LONGDBL) != 0)
|
||||
{
|
||||
long double ldbl = VA_ARG(long double);
|
||||
|
||||
u_put_unalignedp16(cp+2, U_MULTICHAR_CONSTANT16(ch,'\0'));
|
||||
|
||||
U_INTERNAL_PRINT("buf = %s width = %u ldbl = %Lg", buf, ldbl)
|
||||
|
||||
len = sprintf(bp, (const char* restrict)buf, width, ldbl);
|
||||
}
|
||||
else
|
||||
{
|
||||
double dbl = VA_ARG(double);
|
||||
|
||||
u_put_unalignedp16(cp+1, U_MULTICHAR_CONSTANT16(ch,'\0'));
|
||||
|
||||
U_INTERNAL_PRINT("buf = %s width = %u dbl = %g", buf, dbl)
|
||||
|
||||
len = sprintf(bp, (const char* restrict)buf, width, dbl);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
U_INTERNAL_ASSERT_DIFFERS(prec, -1)
|
||||
U_INTERNAL_ASSERT_DIFFERS(width, 0)
|
||||
|
||||
u_put_unalignedp32(cp, U_MULTICHAR_CONSTANT32('*','.','*','L')); /* width, prec, prefix long double */
|
||||
|
||||
if ((flags & LONGDBL) != 0)
|
||||
{
|
||||
long double ldbl = VA_ARG(long double);
|
||||
|
||||
u_put_unalignedp16(cp+4, U_MULTICHAR_CONSTANT16(ch,'\0'));
|
||||
|
||||
U_INTERNAL_PRINT("buf = %s width = %u prec = %d ldbl = %Lg", buf, width, prec, ldbl)
|
||||
|
||||
len = sprintf(bp, (const char* restrict)buf, width, prec, ldbl);
|
||||
}
|
||||
else
|
||||
{
|
||||
double dbl = VA_ARG(double);
|
||||
|
||||
u_put_unalignedp16(cp+3, U_MULTICHAR_CONSTANT16(ch,'\0'));
|
||||
|
||||
U_INTERNAL_PRINT("buf = %s width = %u prec = %d dbl = %g", buf, width, prec, dbl)
|
||||
|
||||
len = sprintf(bp, (const char* restrict)buf, width, prec, dbl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(len, strlen(bp))
|
||||
|
|
|
@ -3595,7 +3595,7 @@ __pure int u_isUTF16(const unsigned char* restrict buf, uint32_t len)
|
|||
*/
|
||||
|
||||
#define U__S 0x00000001 /* character space ' ' (32 0x20) */
|
||||
#define U__E 0x00000002 /* character used in printf format */
|
||||
#define U__E 0x00000002 /* character used in printf format */
|
||||
#define U__H 0x00000004 /* character '+' (43 0x2B) */
|
||||
#define U__V 0x00000008 /* character ',' (44 0x2C) */
|
||||
#define U__O 0x00000010 /* character minus '-' (45 0x2D) */
|
||||
|
|
|
@ -135,15 +135,6 @@ void UFile::setRoot()
|
|||
|
||||
// gcc - call is unlikely and code size would grow
|
||||
|
||||
void UFile::setPath(const UString& path, const UString* environment)
|
||||
{
|
||||
U_TRACE(0, "UFile::setPath(%V,%p)", path.rep, environment)
|
||||
|
||||
pathname = path;
|
||||
|
||||
setPathRelativ(environment);
|
||||
}
|
||||
|
||||
bool UFile::open(int flags)
|
||||
{
|
||||
U_TRACE(0, "UFile::open(%d)", flags)
|
||||
|
@ -151,11 +142,12 @@ bool UFile::open(int flags)
|
|||
U_CHECK_MEMORY
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(fd, -1)
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
U_INTERNAL_ASSERT_MAJOR(path_relativ_len, 0)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
U_INTERNAL_ASSERT_MAJOR(path_relativ_len, 0)
|
||||
|
||||
fd = UFile::open(path_relativ, flags, PERM_FILE);
|
||||
|
||||
if (fd != -1) U_RETURN(true);
|
||||
|
@ -184,10 +176,11 @@ bool UFile::creat(int flags, mode_t mode)
|
|||
U_CHECK_MEMORY
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(fd, -1)
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
fd = UFile::open(path_relativ, O_CREAT | flags, mode);
|
||||
|
||||
if (fd != -1) U_RETURN(true);
|
||||
|
@ -195,25 +188,16 @@ bool UFile::creat(int flags, mode_t mode)
|
|||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool UFile::creat(const UString& path, int flags, mode_t mode)
|
||||
{
|
||||
U_TRACE(0, "UFile::creat(%V,%d,%d)", path.rep, flags, mode)
|
||||
|
||||
setPath(path);
|
||||
|
||||
return creat(flags, mode);
|
||||
}
|
||||
|
||||
bool UFile::stat()
|
||||
{
|
||||
U_TRACE_NO_PARAM(1, "UFile::stat()")
|
||||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
st_ino = 0;
|
||||
|
||||
bool result = (U_SYSCALL(stat, "%S,%p", U_PATH_CONV(path_relativ), (struct stat*)this) == 0);
|
||||
|
@ -706,10 +690,10 @@ bool UFile::memmap(int prot, UString* str, uint32_t offset, uint32_t length)
|
|||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_DIFFERS(fd, -1)
|
||||
U_INTERNAL_ASSERT_MAJOR(st_size, 0)
|
||||
|
||||
|
@ -781,10 +765,10 @@ void UFile::munmap()
|
|||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_MAJOR(map_size,0UL)
|
||||
U_INTERNAL_ASSERT_DIFFERS(map,(char*)MAP_FAILED)
|
||||
|
||||
|
@ -821,9 +805,9 @@ UString UFile::_getContent(bool bsize, bool brdonly, bool bmap)
|
|||
U_INTERNAL_ASSERT_DIFFERS(fd, -1)
|
||||
|
||||
#if defined(DEBUG) && !defined(U_LINUX) && !defined(O_TMPFILE)
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
#endif
|
||||
|
||||
# ifdef U_COVERITY_FALSE_POSITIVE
|
||||
|
@ -933,10 +917,10 @@ bool UFile::creatForWrite(int flags, bool bmkdirs)
|
|||
{
|
||||
U_TRACE(1, "UFile::creatForWrite(%d,%b)", flags, bmkdirs)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
bool esito = isOpen();
|
||||
|
||||
if (esito == false)
|
||||
|
@ -1161,10 +1145,10 @@ bool UFile::ftruncate(uint32_t n)
|
|||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_DIFFERS(fd, -1)
|
||||
#if defined(__CYGWIN__) || defined(_MSWINDOWS_)
|
||||
U_INTERNAL_ASSERT_EQUALS(map, (char*)MAP_FAILED)
|
||||
|
@ -1316,9 +1300,9 @@ bool UFile::pread(void* buf, uint32_t count, uint32_t offset)
|
|||
U_INTERNAL_ASSERT_DIFFERS(fd, -1)
|
||||
|
||||
#if defined(DEBUG) && !defined(U_LINUX) && !defined(O_TMPFILE)
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
#endif
|
||||
|
||||
#ifdef U_COVERITY_FALSE_POSITIVE
|
||||
|
@ -1339,9 +1323,9 @@ bool UFile::pwrite(const void* _buf, uint32_t count, uint32_t offset)
|
|||
U_INTERNAL_ASSERT_DIFFERS(fd, -1)
|
||||
|
||||
#if defined(DEBUG) && !defined(U_LINUX) && !defined(O_TMPFILE)
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
#endif
|
||||
|
||||
#ifdef U_COVERITY_FALSE_POSITIVE
|
||||
|
@ -1611,10 +1595,10 @@ bool UFile::_rename(const char* newpath)
|
|||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
bool result = UFile::_rename(path_relativ, newpath);
|
||||
|
||||
if (result)
|
||||
|
@ -1665,28 +1649,6 @@ void UFile::substitute(UFile& file)
|
|||
if (fd != -1) UFile::fsync();
|
||||
}
|
||||
|
||||
UString UFile::getSuffix() const
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "UFile::getSuffix()")
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(path_relativ)
|
||||
|
||||
U_INTERNAL_DUMP("path_relativ(%u) = %.*S", path_relativ_len, path_relativ_len, path_relativ)
|
||||
|
||||
UString suffix;
|
||||
const char* ptr = u_getsuffix(path_relativ, path_relativ_len);
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(ptr[0], '.')
|
||||
U_INTERNAL_ASSERT_EQUALS(strchr(ptr, '/'), U_NULLPTR)
|
||||
|
||||
(void) suffix.assign(ptr+1, (path_relativ + path_relativ_len) - (1 + ptr)); // 1 => '.'
|
||||
}
|
||||
|
||||
U_RETURN_STRING(suffix);
|
||||
}
|
||||
|
||||
// MIME TYPE
|
||||
|
||||
const char* UFile::getMimeType(const char* suffix, int* pmime_index)
|
||||
|
|
|
@ -29,7 +29,7 @@ int UClientImage_Base::idx;
|
|||
int UClientImage_Base::csfd;
|
||||
int UClientImage_Base::iovcnt;
|
||||
bool UClientImage_Base::bIPv6;
|
||||
bool UClientImage_Base::bsendGzipBomp;
|
||||
bool UClientImage_Base::bsendGzipBomb;
|
||||
char UClientImage_Base::cbuffer[128];
|
||||
long UClientImage_Base::time_run;
|
||||
long UClientImage_Base::time_between_request = 10;
|
||||
|
@ -45,8 +45,8 @@ UString* UClientImage_Base::request;
|
|||
UString* UClientImage_Base::request_uri;
|
||||
UString* UClientImage_Base::environment;
|
||||
UTimeVal* UClientImage_Base::chronometer;
|
||||
struct iovec UClientImage_Base::iov_sav[4];
|
||||
struct iovec UClientImage_Base::iov_vec[4];
|
||||
struct iovec UClientImage_Base::iov_sav[4];
|
||||
struct iovec* UClientImage_Base::piov;
|
||||
|
||||
iPF UClientImage_Base::callerHandlerRead = UServer_Base::pluginsHandlerREAD;
|
||||
|
@ -1019,12 +1019,10 @@ void UClientImage_Base::prepareForRead()
|
|||
#ifdef U_EVASIVE_SUPPORT
|
||||
if (UServer_Base::checkHitSiteStats())
|
||||
{
|
||||
if (U_http_version == '1' &&
|
||||
U_http_is_accept_gzip &&
|
||||
UHTTP::file_gzip_bomb &&
|
||||
if (UHTTP::file_gzip_bomb &&
|
||||
UServer_Base::bssl == false)
|
||||
{
|
||||
bsendGzipBomp = true;
|
||||
bsendGzipBomb = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1139,11 +1137,6 @@ int UClientImage_Base::handlerRead() // Connection-wide hooks
|
|||
|
||||
int result;
|
||||
uint32_t sz;
|
||||
const char* ptr1;
|
||||
/*
|
||||
const char* ptr2;
|
||||
UHTTP::UServletPage* usp;
|
||||
*/
|
||||
|
||||
prepareForRead();
|
||||
|
||||
|
@ -1269,109 +1262,9 @@ data_missing:
|
|||
|
||||
resetBuffer();
|
||||
|
||||
/*
|
||||
ptr1 = rbuffer->c_pointer(3);
|
||||
ptr2 = ptr1 + 8;
|
||||
|
||||
if (u_get_unalignedp64(ptr1) == U_MULTICHAR_CONSTANT64(' ','/','c','a','c','h','e','d') &&
|
||||
u_get_unalignedp64(ptr2) == U_MULTICHAR_CONSTANT64('_','w','o','r','l','d','s','?'))
|
||||
{
|
||||
usp = UHTTP::vusp->at(0);
|
||||
|
||||
for (ptr1 = U_http_info.query = ptr2 + 8 + U_CONSTANT_SIZE("queries"); *ptr1 != ' '; ++ptr1) {}
|
||||
|
||||
U_http_info.query_len = ptr1 - U_http_info.query;
|
||||
|
||||
U_INTERNAL_DUMP("query = %.*S", U_HTTP_QUERY_TO_TRACE)
|
||||
}
|
||||
else if (u_get_unalignedp64(ptr1) == U_MULTICHAR_CONSTANT64(' ','/','d','b',' ','H','T','T'))
|
||||
{
|
||||
usp = UHTTP::vusp->at(1);
|
||||
}
|
||||
else if (u_get_unalignedp64(ptr1) == U_MULTICHAR_CONSTANT64(' ','/','f','o','r','t','u','n') &&
|
||||
u_get_unalignedp64(ptr2) == U_MULTICHAR_CONSTANT64('e',' ','H','T','T','P','/','1'))
|
||||
{
|
||||
usp = UHTTP::vusp->at(2);
|
||||
}
|
||||
else if (u_get_unalignedp64(ptr1) == U_MULTICHAR_CONSTANT64(' ','/','j','s','o','n',' ','H'))
|
||||
{
|
||||
usp = UHTTP::vusp->at(3);
|
||||
}
|
||||
else if (u_get_unalignedp64(ptr1) == U_MULTICHAR_CONSTANT64(' ','/','m','d','b',' ','H','T'))
|
||||
{
|
||||
usp = UHTTP::vusp->at(4);
|
||||
}
|
||||
else if (u_get_unalignedp64(ptr1) == U_MULTICHAR_CONSTANT64(' ','/','m','f','o','r','t','u') &&
|
||||
u_get_unalignedp64(ptr2) == U_MULTICHAR_CONSTANT64('n','e',' ','H','T','T','P','/'))
|
||||
{
|
||||
usp = UHTTP::vusp->at(5);
|
||||
}
|
||||
else if (u_get_unalignedp64(ptr1) == U_MULTICHAR_CONSTANT64(' ','/','m','q','u','e','r','y') &&
|
||||
u_get_unalignedp64(ptr2) == U_MULTICHAR_CONSTANT64('?','q','u','e','r','i','e','s'))
|
||||
{
|
||||
usp = UHTTP::vusp->at(6);
|
||||
|
||||
for (ptr1 = U_http_info.query = ptr2 + 8; *ptr1 != ' '; ++ptr1) {}
|
||||
|
||||
U_http_info.query_len = ptr1 - U_http_info.query;
|
||||
|
||||
U_INTERNAL_DUMP("query = %.*S", U_HTTP_QUERY_TO_TRACE)
|
||||
}
|
||||
else if (u_get_unalignedp64(ptr1) == U_MULTICHAR_CONSTANT64(' ','/','m','u','p','d','a','t') &&
|
||||
u_get_unalignedp64(ptr2) == U_MULTICHAR_CONSTANT64('e','?','q','u','e','r','i','e'))
|
||||
{
|
||||
usp = UHTTP::vusp->at(7);
|
||||
|
||||
for (ptr1 = U_http_info.query = ptr2 + 8 + 1; *ptr1 != ' '; ++ptr1) {}
|
||||
|
||||
U_http_info.query_len = ptr1 - U_http_info.query;
|
||||
|
||||
U_INTERNAL_DUMP("query = %.*S", U_HTTP_QUERY_TO_TRACE)
|
||||
}
|
||||
else if (u_get_unalignedp64(ptr1) == U_MULTICHAR_CONSTANT64(' ','/','q','u','e','r','y','?'))
|
||||
{
|
||||
usp = UHTTP::vusp->at(9);
|
||||
|
||||
for (ptr1 = U_http_info.query = ptr2 + U_CONSTANT_SIZE("queries"); *ptr1 != ' '; ++ptr1) {}
|
||||
|
||||
U_http_info.query_len = ptr1 - U_http_info.query;
|
||||
|
||||
U_INTERNAL_DUMP("query = %.*S", U_HTTP_QUERY_TO_TRACE)
|
||||
}
|
||||
else if (u_get_unalignedp64(ptr1) == U_MULTICHAR_CONSTANT64(' ','/','u','p','d','a','t','e') &&
|
||||
u_get_unalignedp64(ptr2) == U_MULTICHAR_CONSTANT64('?','q','u','e','r','i','e','s'))
|
||||
{
|
||||
usp = UHTTP::vusp->at(10);
|
||||
|
||||
for (ptr1 = U_http_info.query = ptr2 + 8; *ptr1 != ' '; ++ptr1) {}
|
||||
|
||||
U_http_info.query_len = ptr1 - U_http_info.query;
|
||||
|
||||
U_INTERNAL_DUMP("query = %.*S", U_HTTP_QUERY_TO_TRACE)
|
||||
}
|
||||
else
|
||||
{
|
||||
U_INTERNAL_DUMP("ptr1 = %.16S", ptr1)
|
||||
|
||||
goto next1;
|
||||
}
|
||||
|
||||
U_http_content_type_len = 0;
|
||||
|
||||
U_http_info.nResponseCode = HTTP_OK;
|
||||
|
||||
usp->runDynamicPage(0);
|
||||
|
||||
UHTTP::setDynamicResponse();
|
||||
|
||||
UHTTP::ext->clear();
|
||||
|
||||
(void) writeResponse();
|
||||
|
||||
U_RETURN(U_NOTIFIER_OK);
|
||||
|
||||
next1:
|
||||
*/
|
||||
#if defined(U_SERVER_CAPTIVE_PORTAL) && defined(ENABLE_THREAD)
|
||||
if (UHTTP::checkForUSP()) U_RETURN(U_NOTIFIER_OK);
|
||||
#endif
|
||||
|
||||
size_request =
|
||||
U_ClientImage_request = 0;
|
||||
|
@ -1438,7 +1331,7 @@ next2:
|
|||
}
|
||||
else if (size_request < sz) // we check if we have a pipeline...
|
||||
{
|
||||
ptr1 = rbuffer->c_pointer(size_request);
|
||||
const char* ptr1 = rbuffer->c_pointer(size_request);
|
||||
|
||||
if (UNLIKELY(u__isspace(*ptr1))) while (u__isspace(*++ptr1)) {}
|
||||
|
||||
|
|
|
@ -1841,14 +1841,14 @@ void UServer_Base::loadConfigParam()
|
|||
if (preforked_num_kids > 1) monitoring_process = true;
|
||||
|
||||
#ifdef USE_LIBSSL
|
||||
*password = cfg->at(U_CONSTANT_TO_PARAM("PASSWORD"));
|
||||
*ca_file = cfg->at(U_CONSTANT_TO_PARAM("CA_FILE"));
|
||||
*ca_path = cfg->at(U_CONSTANT_TO_PARAM("CA_PATH"));
|
||||
*key_file = cfg->at(U_CONSTANT_TO_PARAM("KEY_FILE"));
|
||||
*cert_file = cfg->at(U_CONSTANT_TO_PARAM("CERT_FILE"));
|
||||
*dh_file = cfg->at(U_CONSTANT_TO_PARAM("DH_FILE"));
|
||||
*ca_file = cfg->at(U_CONSTANT_TO_PARAM("CA_FILE"));
|
||||
*ca_path = cfg->at(U_CONSTANT_TO_PARAM("CA_PATH"));
|
||||
*key_file = cfg->at(U_CONSTANT_TO_PARAM("KEY_FILE"));
|
||||
*password = cfg->at(U_CONSTANT_TO_PARAM("PASSWORD"));
|
||||
*cert_file = cfg->at(U_CONSTANT_TO_PARAM("CERT_FILE"));
|
||||
|
||||
*dh_file = cfg->at(U_CONSTANT_TO_PARAM("DH_FILE"));
|
||||
verify_mode = cfg->at(U_CONSTANT_TO_PARAM("VERIFY_MODE"));
|
||||
verify_mode = cfg->readLong(U_CONSTANT_TO_PARAM("VERIFY_MODE"));
|
||||
|
||||
if (bssl) min_size_for_sendfile = U_NOT_FOUND; // NB: we can't use sendfile with SSL...
|
||||
#endif
|
||||
|
|
|
@ -29,8 +29,6 @@ void UOrmDriverSqlite::handlerError()
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UOrmDriverSqlite::handlerError()")
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(UOrmDriver::connection)
|
||||
|
||||
// Translation table for error status codes
|
||||
|
||||
struct error_value_info {
|
||||
|
@ -76,8 +74,11 @@ void UOrmDriverSqlite::handlerError()
|
|||
U_ENTRY(SQLITE_DONE) /* sqlite3_step() has finished executing */
|
||||
};
|
||||
|
||||
if (UOrmDriver::errmsg == U_NULLPTR) UOrmDriver::errmsg = U_SYSCALL(sqlite3_errmsg, "%p", (sqlite3*)UOrmDriver::connection);
|
||||
if (UOrmDriver::errcode == 0) UOrmDriver::errcode = U_SYSCALL(sqlite3_errcode, "%p", (sqlite3*)UOrmDriver::connection);
|
||||
if (UOrmDriver::connection)
|
||||
{
|
||||
if (UOrmDriver::errmsg == U_NULLPTR) UOrmDriver::errmsg = U_SYSCALL(sqlite3_errmsg, "%p", (sqlite3*)UOrmDriver::connection);
|
||||
if (UOrmDriver::errcode == 0) UOrmDriver::errcode = U_SYSCALL(sqlite3_errcode, "%p", (sqlite3*)UOrmDriver::connection);
|
||||
}
|
||||
|
||||
if (UOrmDriver::errcode >= 0 &&
|
||||
UOrmDriver::errcode < (int)U_NUM_ELEMENTS(error_value_table) &&
|
||||
|
|
|
@ -209,12 +209,12 @@ UOrmStatement::UOrmStatement(UOrmSession& session, const char* stmt, uint32_t le
|
|||
pdrv = (psession = &session)->pdrv;
|
||||
pstmt = pdrv->handlerStatementCreation(stmt, len);
|
||||
|
||||
U_INTERNAL_DUMP("psession = %p pdrv = %p", psession, pdrv)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UOrmDriver::env_driver_len) UOrmSession::loadDriverFail(UOrmDriver::env_driver, UOrmDriver::env_driver_len);
|
||||
U_INTERNAL_DUMP("psession = %p pdrv = %p pstmt = %p", psession, pdrv, pstmt)
|
||||
|
||||
if (pstmt) return;
|
||||
}
|
||||
|
||||
if (UOrmDriver::env_driver_len) UOrmSession::loadDriverFail(UOrmDriver::env_driver, UOrmDriver::env_driver_len);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -1979,9 +1979,13 @@ double UString::strtod() const
|
|||
|
||||
UValue json;
|
||||
|
||||
if (json.parse(*this)) return json.getDouble();
|
||||
if (equal("0", 1) == false &&
|
||||
json.parse(*this))
|
||||
{
|
||||
return json.getDouble();
|
||||
}
|
||||
|
||||
U_RETURN(0);
|
||||
U_RETURN(.0);
|
||||
}
|
||||
|
||||
void UString::printKeyValue(const char* key, uint32_t keylen, const char* _data, uint32_t datalen)
|
||||
|
|
|
@ -110,8 +110,6 @@ uint32_t UHTTP::limit_request_body = U_STRING_MAX_SIZE;
|
|||
uint32_t UHTTP::request_read_timeout;
|
||||
|
||||
UCommand* UHTTP::pcmd;
|
||||
const char* UHTTP::uri_suffix;
|
||||
const char* UHTTP::uri_basename;
|
||||
UDataSession* UHTTP::data_session;
|
||||
UDataSession* UHTTP::data_storage;
|
||||
UMimeMultipart* UHTTP::formMulti;
|
||||
|
@ -816,6 +814,8 @@ U_NO_EXPORT void UHTTP::loadStaticLinkedServlet(const char* name, uint32_t len,
|
|||
if (pathname->equal(U_CONSTANT_TO_PARAM("wi_auth"))) (void) pathname->insert(0, U_CONSTANT_TO_PARAM(WI_AUTH_DOMAIN "/servlet/"));
|
||||
# endif
|
||||
|
||||
U_ASSERT_EQUALS(cache_file->find(*pathname), false)
|
||||
|
||||
cache_file->insert(*pathname, file_data); // NB: we don't need to call u_construct<UHTTP::UFileCacheData>()...
|
||||
|
||||
U_SRV_LOG("linked static servlet: %.*S, USP service registered (URI): %V", len, name, pathname->rep);
|
||||
|
@ -3597,16 +3597,16 @@ U_NO_EXPORT bool UHTTP::callService()
|
|||
|
||||
pathname->setBuffer(U_CAPACITY);
|
||||
|
||||
uri_suffix = u_getsuffix(U_FILE_TO_PARAM(*file));
|
||||
const char* suffix = u_getsuffix(U_FILE_TO_PARAM(*file));
|
||||
|
||||
if (uri_suffix) pathname->snprintf(U_CONSTANT_TO_PARAM("%.*s"), U_FILE_TO_TRACE(*file));
|
||||
else pathname->snprintf(U_CONSTANT_TO_PARAM("%.*s.%s"), U_FILE_TO_TRACE(*file), U_LIB_SUFFIX);
|
||||
if (suffix) pathname->snprintf(U_CONSTANT_TO_PARAM("%.*s"), U_FILE_TO_TRACE(*file));
|
||||
else pathname->snprintf(U_CONSTANT_TO_PARAM("%.*s.%s"), U_FILE_TO_TRACE(*file), U_LIB_SUFFIX);
|
||||
|
||||
file->setPath(*pathname);
|
||||
|
||||
while (file->stat() == false)
|
||||
{
|
||||
if (uri_suffix) U_RETURN(false);
|
||||
if (suffix) U_RETURN(false);
|
||||
|
||||
pathname->setBuffer(U_CAPACITY);
|
||||
|
||||
|
@ -3614,14 +3614,14 @@ U_NO_EXPORT bool UHTTP::callService()
|
|||
|
||||
file->setPath(*pathname);
|
||||
|
||||
uri_suffix = (const char*)U_INT2PTR(0xffff);
|
||||
suffix = ".usp";
|
||||
}
|
||||
|
||||
U_INTERNAL_DUMP("U_http_is_nocache_file = %b", U_http_is_nocache_file)
|
||||
|
||||
if (U_http_is_nocache_file == false)
|
||||
{
|
||||
manageDataForCache(UStringExt::basename(file->getPath()));
|
||||
manageDataForCache(UStringExt::basename(file->getPath()), file->getSuffix());
|
||||
|
||||
if (file_data)
|
||||
{
|
||||
|
@ -4096,37 +4096,45 @@ int UHTTP::handlerREAD()
|
|||
# endif
|
||||
}
|
||||
|
||||
U_INTERNAL_DUMP("UClientImage_Base::size_request = %u UClientImage_Base::bsendGzipBomp = %b", UClientImage_Base::size_request, UClientImage_Base::bsendGzipBomp)
|
||||
U_INTERNAL_DUMP("UClientImage_Base::size_request = %u UClientImage_Base::bsendGzipBomb = %b", UClientImage_Base::size_request, UClientImage_Base::bsendGzipBomb)
|
||||
|
||||
#ifndef U_SERVER_CAPTIVE_PORTAL
|
||||
if (UClientImage_Base::bsendGzipBomp)
|
||||
if (UClientImage_Base::bsendGzipBomb)
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(UServer_Base::bssl, false) // NB: we can't use sendfile with SSL...
|
||||
|
||||
UClientImage_Base::bsendGzipBomp = false;
|
||||
UClientImage_Base::bsendGzipBomb = false;
|
||||
|
||||
U_DEBUG("we strike back sending gzip bomb...", 0);
|
||||
if (U_http_version == '1' &&
|
||||
U_http_is_accept_gzip)
|
||||
{
|
||||
U_DEBUG("we strike back sending gzip bomb...", 0);
|
||||
|
||||
U_SRV_LOG("we strike back sending gzip bomb...", 0);
|
||||
U_SRV_LOG("we strike back sending gzip bomb...", 0);
|
||||
|
||||
if (UServer_Base::startParallelization()) U_RETURN(U_PLUGIN_HANDLER_FINISHED); // parent
|
||||
if (UServer_Base::startParallelization()) U_RETURN(U_PLUGIN_HANDLER_FINISHED); // parent
|
||||
|
||||
UClientImage_Base::body->clear();
|
||||
UClientImage_Base::body->clear();
|
||||
|
||||
UClientImage_Base::setCloseConnection();
|
||||
UClientImage_Base::setCloseConnection();
|
||||
|
||||
U_http_flag |= HTTP_IS_RESPONSE_GZIP | HTTP_IS_SENDFILE;
|
||||
U_ClientImage_request |= UClientImage_Base::ALREADY_PROCESSED | UClientImage_Base::NO_CACHE;
|
||||
U_http_flag |= HTTP_IS_RESPONSE_GZIP | HTTP_IS_SENDFILE;
|
||||
U_ClientImage_request |= UClientImage_Base::ALREADY_PROCESSED | UClientImage_Base::NO_CACHE;
|
||||
|
||||
UClientImage_Base::setSendfile(file_gzip_bomb->fd, 0, file_gzip_bomb->size);
|
||||
UClientImage_Base::setSendfile(file_gzip_bomb->fd, 0, file_gzip_bomb->size);
|
||||
|
||||
U_http_info.nResponseCode = HTTP_OK;
|
||||
U_http_info.nResponseCode = HTTP_OK;
|
||||
|
||||
*ext = file_gzip_bomb->array->operator[](0);
|
||||
*ext = file_gzip_bomb->array->operator[](0);
|
||||
|
||||
handlerResponse();
|
||||
handlerResponse();
|
||||
|
||||
U_RETURN(U_PLUGIN_HANDLER_FINISHED);
|
||||
U_RETURN(U_PLUGIN_HANDLER_FINISHED);
|
||||
}
|
||||
|
||||
UClientImage_Base::abortive_close();
|
||||
|
||||
U_RETURN(U_PLUGIN_HANDLER_ERROR);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -4222,7 +4230,7 @@ int UHTTP::manageRequest()
|
|||
|
||||
// manage global alias
|
||||
|
||||
U_INTERNAL_DUMP("global_alias = %b UClientImage_Base::request_uri(%u) = %V",
|
||||
U_INTERNAL_DUMP("global_alias = %p UClientImage_Base::request_uri(%u) = %V",
|
||||
global_alias, UClientImage_Base::request_uri->size(), UClientImage_Base::request_uri->rep)
|
||||
|
||||
if (global_alias &&
|
||||
|
@ -4403,7 +4411,7 @@ manage:
|
|||
|
||||
file->setPath(*pathname);
|
||||
|
||||
manageDataForCache(UStringExt::basename(file->getPath()));
|
||||
manageDataForCache(UStringExt::basename(file->getPath()), U_STRING_FROM_CONSTANT("usp"));
|
||||
|
||||
if (file_data) UClientImage_Base::setRequestInFileCache();
|
||||
}
|
||||
|
@ -6764,7 +6772,8 @@ void UHTTP::setRedirectResponse(int mode, const char* ptr_location, uint32_t len
|
|||
|
||||
if ((mode & NETWORK_AUTHENTICATION_REQUIRED) != 0)
|
||||
{
|
||||
len = u__snprintf(msg, sizeof(msg), U_CONSTANT_TO_PARAM("You need to <a href=\"%.*s\">authenticate with the local network</a> in order to get access"), len_location, ptr_location);
|
||||
len = u__snprintf(msg, sizeof(msg), U_CONSTANT_TO_PARAM("You need to <a href=\"%.*s\">authenticate with the local network</a> in order to get access"),
|
||||
len_location, ptr_location);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -6792,7 +6801,7 @@ void UHTTP::setErrorResponse(const UString& content_type, int code, const char*
|
|||
|
||||
U_INTERNAL_ASSERT(U_IS_HTTP_ERROR(code))
|
||||
|
||||
UClientImage_Base::setCloseConnection();
|
||||
if (code != HTTP_UNAUTHORIZED) UClientImage_Base::setCloseConnection();
|
||||
|
||||
U_INTERNAL_DUMP("U_http_is_request_nostat = %b U_HTTP_URI_QUERY_LEN = %u", U_http_is_request_nostat, U_HTTP_URI_QUERY_LEN)
|
||||
|
||||
|
@ -7055,18 +7064,49 @@ U_NO_EXPORT bool UHTTP::processAuthorization()
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UHTTP::processAuthorization()")
|
||||
|
||||
UTokenizer t;
|
||||
uint32_t sz, pos = 0;
|
||||
bool result = false, bpass = false;
|
||||
const char* ptr = getHeaderValuePtr(U_CONSTANT_TO_PARAM("Authorization"), false);
|
||||
const char* ptr = UClientImage_Base::getRequestUri(sz);
|
||||
UString buffer(100U), fpasswd, content, tmp, user(100U);
|
||||
const char* uri_suffix = u_getsuffix(ptr, sz);
|
||||
|
||||
if (uri_suffix)
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(uri_suffix[0], '.')
|
||||
|
||||
pos = (ptr + sz) - uri_suffix;
|
||||
}
|
||||
|
||||
U_INTERNAL_DUMP("digest_authentication = %b", digest_authentication)
|
||||
|
||||
buffer.snprintf(U_CONSTANT_TO_PARAM("..%.*s.ht%6s"), sz-pos, ptr, digest_authentication ? "digest" : "passwd");
|
||||
|
||||
UHTTP::UFileCacheData* ptr_file_data = cache_file->at(U_STRING_TO_PARAM(buffer));
|
||||
|
||||
U_INTERNAL_DUMP("ptr_file_data = %p htpasswd = %p", ptr_file_data, htpasswd)
|
||||
|
||||
if (ptr_file_data) fpasswd = ptr_file_data->array->operator[](0);
|
||||
else
|
||||
{
|
||||
if (digest_authentication)
|
||||
{
|
||||
if (htdigest) fpasswd = *htdigest;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (htpasswd) fpasswd = *htpasswd;
|
||||
}
|
||||
}
|
||||
|
||||
if (fpasswd.empty()) goto end;
|
||||
|
||||
bpass = true;
|
||||
|
||||
ptr = getHeaderValuePtr(U_CONSTANT_TO_PARAM("Authorization"), false);
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
UTokenizer t;
|
||||
uint32_t sz, pos = 0;
|
||||
UHTTP::UFileCacheData* ptr_file_data;
|
||||
UString content, tmp, user(100U), buffer(100U), fpasswd;
|
||||
|
||||
U_INTERNAL_DUMP("digest_authentication = %b", digest_authentication)
|
||||
|
||||
if (digest_authentication)
|
||||
{
|
||||
if (u_get_unalignedp32(ptr) != U_MULTICHAR_CONSTANT32('D','i','g','e')) goto end;
|
||||
|
@ -7087,40 +7127,6 @@ U_NO_EXPORT bool UHTTP::processAuthorization()
|
|||
|
||||
if (t.next(content, (bool*)U_NULLPTR) == false) goto end;
|
||||
|
||||
ptr = UClientImage_Base::getRequestUri(sz);
|
||||
|
||||
uri_suffix = u_getsuffix(ptr, sz);
|
||||
|
||||
if (uri_suffix)
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(uri_suffix[0], '.')
|
||||
|
||||
pos = (ptr + sz) - uri_suffix;
|
||||
}
|
||||
|
||||
buffer.snprintf(U_CONSTANT_TO_PARAM("..%.*s.ht%6s"), sz-pos, ptr, digest_authentication ? "digest" : "passwd");
|
||||
|
||||
ptr_file_data = cache_file->at(U_STRING_TO_PARAM(buffer));
|
||||
|
||||
U_INTERNAL_DUMP("ptr_file_data = %p htpasswd = %p", ptr_file_data, htpasswd)
|
||||
|
||||
if (ptr_file_data) fpasswd = ptr_file_data->array->operator[](0);
|
||||
else
|
||||
{
|
||||
if (digest_authentication)
|
||||
{
|
||||
if (htdigest) fpasswd = *htdigest;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (htpasswd) fpasswd = *htpasswd;
|
||||
}
|
||||
}
|
||||
|
||||
if (fpasswd.empty()) goto end;
|
||||
|
||||
bpass = true;
|
||||
|
||||
if (digest_authentication)
|
||||
{
|
||||
/**
|
||||
|
@ -7313,8 +7319,8 @@ U_NO_EXPORT bool UHTTP::processAuthorization()
|
|||
}
|
||||
}
|
||||
}
|
||||
end:
|
||||
U_SRV_LOG("%srequest authorization for user %V %s", result ? "" : "WARNING: ", user.rep, result ? "success" : "failed");
|
||||
|
||||
end: U_SRV_LOG("%srequest authorization for user %V %s", result ? "" : "WARNING: ", user.rep, result ? "success" : "failed");
|
||||
}
|
||||
|
||||
if (result == false)
|
||||
|
@ -7585,7 +7591,9 @@ not_found:
|
|||
int32_t cmp = -1, probe, low = -1;
|
||||
const char* target = UClientImage_Base::getRequestUri(target_len);
|
||||
|
||||
if (target[0] != '/') goto not_found; // NB: skip '/'...
|
||||
// NB: skip first char of uri ('/')...
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(target[0], '/')
|
||||
|
||||
target += 1;
|
||||
target_len -= 1;
|
||||
|
@ -7594,43 +7602,45 @@ not_found:
|
|||
|
||||
if (target_len == 0) goto not_found; // NB: skip '/' request...
|
||||
|
||||
if (u_getsuffix(target, target_len) != U_NULLPTR) goto end; // NB: if we have a suffix (Ex: something.sh) we go to the next phase of request processing...
|
||||
|
||||
U_http_info.nResponseCode = 0; // NB: it is used by server_plugin_ssi to continue processing with a shell script...
|
||||
|
||||
if (u_getsuffix(target, target_len) == U_NULLPTR) // NB: else we go to the next phase of request processing...
|
||||
while ((high - low) > 1)
|
||||
{
|
||||
while ((high - low) > 1)
|
||||
{
|
||||
probe = ((low + high) & 0xFFFFFFFFL) >> 1;
|
||||
probe = ((low + high) & 0xFFFFFFFFL) >> 1;
|
||||
|
||||
U_INTERNAL_DUMP("low = %d high = %d probe = %d", low, high, probe)
|
||||
U_INTERNAL_DUMP("low = %d high = %d probe = %d", low, high, probe)
|
||||
|
||||
key = table + probe;
|
||||
key = table + probe;
|
||||
|
||||
U_INTERNAL_DUMP("key(%u) = %.*S", key->len, key->len, key->name)
|
||||
U_INTERNAL_DUMP("key(%u) = %.*S", key->len, key->len, key->name)
|
||||
|
||||
cmp = memcmp(key->name, target, U_min(key->len, target_len));
|
||||
cmp = memcmp(key->name, target, U_min(key->len, target_len));
|
||||
|
||||
if (cmp == 0) cmp = (key->len - target_len);
|
||||
if (cmp == 0) cmp = (key->len - target_len);
|
||||
|
||||
if (cmp > 0) high = probe;
|
||||
else if (cmp == 0) goto found;
|
||||
else low = probe;
|
||||
}
|
||||
if (cmp > 0) high = probe;
|
||||
else if (cmp == 0) goto found;
|
||||
else low = probe;
|
||||
}
|
||||
|
||||
if (low == -1 ||
|
||||
(key = table + low, key->len != target_len || memcmp(key->name, target, target_len)))
|
||||
{
|
||||
goto not_found;
|
||||
}
|
||||
if (low == -1 ||
|
||||
(key = table + low, key->len != target_len || memcmp(key->name, target, target_len)))
|
||||
{
|
||||
goto not_found;
|
||||
}
|
||||
|
||||
probe = low;
|
||||
probe = low;
|
||||
|
||||
found:
|
||||
table[probe].function();
|
||||
table[probe].function();
|
||||
|
||||
U_INTERNAL_DUMP("U_http_info.nResponseCode = %u", U_http_info.nResponseCode)
|
||||
U_INTERNAL_DUMP("U_http_info.nResponseCode = %u", U_http_info.nResponseCode)
|
||||
|
||||
if (U_http_info.nResponseCode == 0) (void) UClientImage_Base::environment->append(U_CONSTANT_TO_PARAM("HTTP_RESPONSE_CODE=0\n"));
|
||||
if (U_http_info.nResponseCode == 0)
|
||||
{
|
||||
end: (void) UClientImage_Base::environment->append(U_CONSTANT_TO_PARAM("HTTP_RESPONSE_CODE=0\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7986,13 +7996,15 @@ void UHTTP::checkFileForCache()
|
|||
|
||||
file->setPath(*pathname);
|
||||
|
||||
UString file_name = UStringExt::basename(file->getPath());
|
||||
UString basename = UStringExt::basename(file->getPath());
|
||||
|
||||
U_INTERNAL_ASSERT(file_name)
|
||||
U_INTERNAL_ASSERT(basename)
|
||||
|
||||
const char* suffix = u_getsuffix(U_STRING_TO_PARAM(basename));
|
||||
|
||||
#ifdef DEBUG
|
||||
if (file->isSuffixSwap() || // NB: vi tmp...
|
||||
UServices::dosMatchExtWithOR(file_name, U_CONSTANT_TO_PARAM("stack.*.[0-9]*|mempool.*.[0-9]*|trace.*.[0-9]*|*usp_translator*"), 0))
|
||||
if (u_isSuffixSwap(suffix) || // NB: vi tmp...
|
||||
UServices::dosMatchExtWithOR(basename, U_CONSTANT_TO_PARAM("stack.*.[0-9]*|mempool.*.[0-9]*|trace.*.[0-9]*|*usp_translator*"), 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -8002,45 +8014,37 @@ void UHTTP::checkFileForCache()
|
|||
{
|
||||
U_INTERNAL_DUMP("nocache_file_mask = %p U_http_is_nocache_file = %b", nocache_file_mask, U_http_is_nocache_file)
|
||||
|
||||
if (U_http_is_nocache_file ||
|
||||
(nocache_file_mask &&
|
||||
UServices::dosMatchWithOR(file_name, U_STRING_TO_PARAM(*nocache_file_mask), 0)))
|
||||
if (U_http_is_nocache_file == false &&
|
||||
(nocache_file_mask == U_NULLPTR ||
|
||||
UServices::dosMatchWithOR(basename, U_STRING_TO_PARAM(*nocache_file_mask), 0) == false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (pathname->equal(U_FILE_TO_PARAM(*file)) == false) (void) pathname->replace(U_FILE_TO_PARAM(*file)); // NB: it can happen with inotify...
|
||||
|
||||
manageDataForCache(file_name);
|
||||
manageDataForCache(basename, file->getSuffix(suffix));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name)
|
||||
U_NO_EXPORT void UHTTP::manageDataForCache(const UString& basename, const UString& suffix)
|
||||
{
|
||||
U_TRACE(1, "UHTTP::manageDataForCache(%V)", file_name.rep)
|
||||
U_TRACE(1, "UHTTP::manageDataForCache(%V,%V)", basename.rep, suffix.rep)
|
||||
|
||||
UString suffix;
|
||||
const char* ctype;
|
||||
uint32_t suffix_len;
|
||||
const char* suffix_ptr;
|
||||
|
||||
uint32_t file_name_len = file_name.size();
|
||||
const char* file_name_ptr = file_name.data();
|
||||
const char* basename_ptr;
|
||||
uint32_t suffix_len, basename_len;
|
||||
|
||||
uint32_t file_len = file->getPathRelativLen();
|
||||
const char* file_ptr = file->getPathRelativ();
|
||||
|
||||
U_INTERNAL_DUMP("pathname = %V file = %.*S rpathname = %V", pathname->rep, file_len, file_ptr, rpathname->rep)
|
||||
|
||||
U_INTERNAL_ASSERT(file_name)
|
||||
U_INTERNAL_ASSERT(basename)
|
||||
U_INTERNAL_ASSERT_POINTER(file)
|
||||
U_INTERNAL_ASSERT_POINTER(pathname)
|
||||
U_INTERNAL_ASSERT_POINTER(cache_file)
|
||||
|
||||
/*
|
||||
if (pathname->equal(file_ptr, file_len) == false)
|
||||
{
|
||||
U_DEBUG("UHTTP::manageDataForCache(%V) pathname(%u) = %V file(%u) = %.*S", file_name.rep, pathname->size(), pathname->rep, file_len, file_len, file_ptr)
|
||||
}
|
||||
*/
|
||||
U_ASSERT_EQUALS(suffix, file->getSuffix())
|
||||
U_ASSERT(pathname->equal(file_ptr, file_len))
|
||||
|
||||
U_NEW(UHTTP::UFileCacheData, file_data, UHTTP::UFileCacheData);
|
||||
|
||||
|
@ -8131,8 +8135,7 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name)
|
|||
}
|
||||
#endif
|
||||
|
||||
suffix_len = (suffix = file->getSuffix()).size();
|
||||
suffix_ptr = (suffix_len ? suffix.data() : U_NULLPTR);
|
||||
suffix_ptr = ((suffix_len = suffix.size()) ? suffix.data() : U_NULLPTR);
|
||||
|
||||
if (u_dosmatch(file_ptr, file_len, U_CONSTANT_TO_PARAM("*cgi-bin/*"), 0))
|
||||
{
|
||||
|
@ -8197,60 +8200,60 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name)
|
|||
goto error;
|
||||
}
|
||||
|
||||
basename_len = basename.size();
|
||||
basename_ptr = basename.data();
|
||||
|
||||
if (suffix_len)
|
||||
{
|
||||
// manage authorization data...
|
||||
|
||||
if (suffix_len == 8)
|
||||
{
|
||||
if (u_get_unalignedp64(suffix_ptr) == U_MULTICHAR_CONSTANT64('h','t','p','a','s','s','w','d'))
|
||||
if (u_get_unalignedp64(suffix_ptr) == U_MULTICHAR_CONSTANT64('h','t','p','a','s','s','w','d') ||
|
||||
u_get_unalignedp64(suffix_ptr) == U_MULTICHAR_CONSTANT64('h','t','d','i','g','e','s','t'))
|
||||
{
|
||||
if (u_get_unalignedp16(file_ptr) != U_MULTICHAR_CONSTANT16('.','.'))
|
||||
{
|
||||
U_WARNING("Find file data users permission (%V - %u bytes) inside DOCUMENT_ROOT (%w), for security reason it must be moved into the directory up",
|
||||
pathname->rep, file_data->size);
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
UString content = file->getContent(true, false, true);
|
||||
|
||||
if (u_get_unalignedp32(file_ptr) == U_MULTICHAR_CONSTANT32('.','.','/','.'))
|
||||
if (u_get_unalignedp16(file_ptr+2) != U_MULTICHAR_CONSTANT16('/','.'))
|
||||
{
|
||||
U_NEW(UVector<UString>, file_data->array, UVector<UString>(1U));
|
||||
|
||||
file_data->array->push_back(content);
|
||||
|
||||
U_SRV_LOG("File data users permission: %V loaded - %u bytes", pathname->rep, file_data->size);
|
||||
|
||||
goto end;
|
||||
}
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(file_len, 12)
|
||||
|
||||
if (u_get_unalignedp64(suffix_ptr) == U_MULTICHAR_CONSTANT64('h','t','p','a','s','s','w','d'))
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(file_len, 12)
|
||||
U_INTERNAL_ASSERT_EQUALS(htpasswd, U_NULLPTR)
|
||||
|
||||
U_NEW(UString, htpasswd, UString(content));
|
||||
|
||||
U_SRV_LOG("File data users permission: ../.htpasswd loaded - %u bytes", file_data->size);
|
||||
|
||||
goto error;
|
||||
U_SRV_LOG("File data users permission: %V loaded - %u bytes", pathname->rep, file_data->size);
|
||||
}
|
||||
|
||||
U_NEW(UVector<UString>, file_data->array, UVector<UString>(1U));
|
||||
|
||||
file_data->array->push_back(content);
|
||||
|
||||
U_SRV_LOG("File data users permission: %V loaded - %u bytes", pathname->rep, file_data->size);
|
||||
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (u_get_unalignedp64(suffix_ptr) == U_MULTICHAR_CONSTANT64('h','t','d','i','g','e','s','t'))
|
||||
{
|
||||
UString content = file->getContent(true, false, true);
|
||||
|
||||
if (u_get_unalignedp32(file_ptr) == U_MULTICHAR_CONSTANT32('.','.','/','.'))
|
||||
else
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(file_len, 12)
|
||||
U_INTERNAL_ASSERT_EQUALS(htdigest, U_NULLPTR)
|
||||
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(suffix_ptr), U_MULTICHAR_CONSTANT64('h','t','d','i','g','e','s','t'))
|
||||
|
||||
U_NEW(UString, htdigest, UString(content));
|
||||
|
||||
U_SRV_LOG("File data users permission: ../.htdigest loaded - %u bytes", file_data->size);
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
U_NEW(UVector<UString>, file_data->array, UVector<UString>(1U));
|
||||
|
||||
file_data->array->push_back(content);
|
||||
|
||||
U_SRV_LOG("File data users permission: %V loaded - %u bytes", pathname->rep, file_data->size);
|
||||
|
||||
goto end;
|
||||
goto error;
|
||||
}
|
||||
|
||||
goto check;
|
||||
|
@ -8258,10 +8261,10 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name)
|
|||
|
||||
// manage gzip bomb...
|
||||
|
||||
if (suffix_len == 2 &&
|
||||
UServer_Base::bssl != false && // NB: we can't use sendfile with SSL...
|
||||
u_get_unalignedp16( suffix_ptr) == U_MULTICHAR_CONSTANT16('g','z') &&
|
||||
u_get_unalignedp64(file_name_ptr) == U_MULTICHAR_CONSTANT64('_','_','B','o','m','B','_','_'))
|
||||
if (suffix_len == 2 &&
|
||||
UServer_Base::bssl != false && // NB: we can't use sendfile with SSL...
|
||||
u_get_unalignedp16( suffix_ptr) == U_MULTICHAR_CONSTANT16('g','z') &&
|
||||
u_get_unalignedp64(basename_ptr) == U_MULTICHAR_CONSTANT64('_','_','B','o','m','B','_','_'))
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(file_gzip_bomb, U_NULLPTR)
|
||||
|
||||
|
@ -8290,8 +8293,8 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name)
|
|||
|
||||
// NB: when a pathfile ends with "*.[so|usp|c|dll]" it is assumed to be a dynamic page...
|
||||
|
||||
if (UServices::dosMatch( file_name_ptr, file_name_len, U_CONSTANT_TO_PARAM("*.0.so"), 0) == false && // MACOSX
|
||||
UServices::dosMatchWithOR(file_name_ptr, file_name_len, U_CONSTANT_TO_PARAM("*.so|*.usp|*.c|*.dll"), 0))
|
||||
if (UServices::dosMatch( basename_ptr, basename_len, U_CONSTANT_TO_PARAM("*.0.so"), 0) == false && // MACOSX
|
||||
UServices::dosMatchWithOR(basename_ptr, basename_len, U_CONSTANT_TO_PARAM("*.so|*.usp|*.c|*.dll"), 0))
|
||||
{
|
||||
bool usp_dll = false,
|
||||
usp_src = (suffix_len == 3 &&
|
||||
|
@ -8307,6 +8310,8 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name)
|
|||
{
|
||||
(void) pathname->shrink();
|
||||
|
||||
U_ASSERT_EQUALS(cache_file->find(*pathname), false)
|
||||
|
||||
cache_file->insert(*pathname, file_data);
|
||||
|
||||
U_NEW(UHTTP::UFileCacheData, file_data, UHTTP::UFileCacheData);
|
||||
|
@ -8317,8 +8322,8 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name)
|
|||
file_data->mime_index = U_usp;
|
||||
}
|
||||
|
||||
uint32_t len = file_len -suffix_len-1, // NB: we must avoid the point '.' before the suffix...
|
||||
name_len = file_name_len-suffix_len-1;
|
||||
uint32_t len = file_len -suffix_len-1, // NB: we must avoid the point '.' before the suffix...
|
||||
name_len = basename_len-suffix_len-1;
|
||||
|
||||
U_INTERNAL_ASSERT_MAJOR(len, 0)
|
||||
U_INTERNAL_ASSERT_MAJOR(name_len, 0)
|
||||
|
@ -8328,7 +8333,7 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name)
|
|||
|
||||
struct stat st;
|
||||
char buffer[U_PATH_MAX];
|
||||
UServletPage* usp = getUSP(file_name_ptr, name_len);
|
||||
UServletPage* usp = getUSP(basename_ptr, name_len);
|
||||
|
||||
if (usp)
|
||||
{
|
||||
|
@ -8338,7 +8343,7 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name)
|
|||
file_data->ptr = usp;
|
||||
file_data->link = true;
|
||||
|
||||
U_SRV_LOG("USP found: %.*S (link), USP service registered (URI): %V", file_name_len, file_name_ptr, pathname->rep);
|
||||
U_SRV_LOG("USP found: %V (link), USP service registered (URI): %V", basename.rep, pathname->rep);
|
||||
|
||||
goto end;
|
||||
}
|
||||
|
@ -8358,14 +8363,14 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name)
|
|||
|
||||
if (usp == U_NULLPTR)
|
||||
{
|
||||
U_NEW(UHTTP::UServletPage, usp, UHTTP::UServletPage(file_ptr, len, file_name_ptr, name_len));
|
||||
U_NEW(UHTTP::UServletPage, usp, UHTTP::UServletPage(file_ptr, len, basename_ptr, name_len));
|
||||
}
|
||||
|
||||
if (usp->load() == false) goto error;
|
||||
|
||||
file_data->ptr = usp;
|
||||
|
||||
U_SRV_LOG("USP found: %.*S, USP service registered (URI): %V", file_name_len, file_name_ptr, pathname->rep);
|
||||
U_SRV_LOG("USP found: %V, USP service registered (URI): %V", basename.rep, pathname->rep);
|
||||
}
|
||||
# ifdef HAVE_LIBTCC
|
||||
else if (suffix_len == 1 &&
|
||||
|
@ -8394,7 +8399,7 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name)
|
|||
|
||||
(void) pathname->replace(file_ptr, file_len - U_CONSTANT_SIZE(".c"));
|
||||
|
||||
U_SRV_LOG("CSP found: %.*S, CSP service registered (URI): %V", file_name_len, file_name_ptr, pathname->rep);
|
||||
U_SRV_LOG("CSP found: %V, CSP service registered (URI): %V", basename.rep, pathname->rep);
|
||||
}
|
||||
# endif
|
||||
|
||||
|
@ -8423,7 +8428,7 @@ check:
|
|||
}
|
||||
|
||||
if (cache_file_mask &&
|
||||
UServices::dosMatchWithOR(file_name_ptr, file_name_len, U_STRING_TO_PARAM(*cache_file_mask), 0))
|
||||
UServices::dosMatchWithOR(basename_ptr, basename_len, U_STRING_TO_PARAM(*cache_file_mask), 0))
|
||||
{
|
||||
ctype = setMimeIndex(suffix_ptr);
|
||||
|
||||
|
@ -8460,6 +8465,8 @@ end:
|
|||
|
||||
(void) pathname->shrink();
|
||||
|
||||
U_ASSERT_EQUALS(cache_file->find(*pathname), false)
|
||||
|
||||
cache_file->insert(*pathname, file_data); // NB: we don't need to call u_construct<UHTTP::UFileCacheData>()...
|
||||
|
||||
return;
|
||||
|
@ -8769,16 +8776,18 @@ nocontent: UClientImage_Base::setCloseConnection();
|
|||
if (file->stat())
|
||||
# endif
|
||||
{
|
||||
uri_suffix = u_getsuffix(U_STRING_TO_PARAM(basename));
|
||||
UString suffix;
|
||||
|
||||
if (uri_suffix)
|
||||
ptr = u_getsuffix(U_STRING_TO_PARAM(basename));
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
uint32_t n = u__strlen(++uri_suffix, __PRETTY_FUNCTION__);
|
||||
len = u__strlen(++ptr, __PRETTY_FUNCTION__);
|
||||
|
||||
if (U_STREQ(uri_suffix, n, U_LIB_SUFFIX)) goto nocontent;
|
||||
if (U_STREQ(ptr, len, U_LIB_SUFFIX)) goto nocontent;
|
||||
|
||||
if (U_HTTP_QUERY_STREQ("_nav_") &&
|
||||
U_STREQ(uri_suffix, n, "usp"))
|
||||
U_STREQ(ptr, len, "usp"))
|
||||
{
|
||||
UClientImage_Base::setRequestNeedProcessing();
|
||||
}
|
||||
|
@ -8792,7 +8801,11 @@ nocontent: UClientImage_Base::setCloseConnection();
|
|||
|
||||
U_ASSERT_EQUALS(basename, UStringExt::basename(file->getPath()))
|
||||
|
||||
manageDataForCache(basename);
|
||||
if (len) (void) suffix.assign(ptr, len);
|
||||
|
||||
(void) pathname->replace(U_FILE_TO_PARAM(*file));
|
||||
|
||||
manageDataForCache(basename, suffix);
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(file_data)
|
||||
}
|
||||
|
@ -11006,6 +11019,80 @@ found:
|
|||
U_RETURN_POINTER(usp, UHTTP::UServletPage);
|
||||
}
|
||||
|
||||
bool UHTTP::checkForUSP()
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "UHTTP::checkForUSP()")
|
||||
|
||||
unsigned char* ptr = (unsigned char*)UClientImage_Base::rbuffer->c_pointer(3);
|
||||
|
||||
U_INTERNAL_DUMP("ptr = %.16S", ptr)
|
||||
|
||||
if (u_get_unalignedp16(ptr) == U_MULTICHAR_CONSTANT16(' ','/'))
|
||||
{
|
||||
static uint32_t old_sz;
|
||||
static UServletPage* old_usp;
|
||||
|
||||
uint32_t sz;
|
||||
UServletPage* usp;
|
||||
unsigned char* ptr1 = (ptr += 2);
|
||||
|
||||
loop: while (u__isalpha(*++ptr1)) {}
|
||||
|
||||
if (*ptr1 == '_') goto loop;
|
||||
|
||||
sz = ptr1-ptr;
|
||||
|
||||
U_INTERNAL_DUMP("uri = %.*S", sz, ptr)
|
||||
|
||||
if (sz == old_sz)
|
||||
{
|
||||
U_ASSERT(old_usp->basename.equal((const char*)ptr, sz))
|
||||
|
||||
usp = old_usp;
|
||||
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (u_get_unalignedp64(ptr) != U_MULTICHAR_CONSTANT64('p','l','a','i','n','t','e','x'))
|
||||
{
|
||||
usp = getUSP((const char*)ptr, sz);
|
||||
|
||||
if (usp)
|
||||
{
|
||||
old_sz = sz;
|
||||
old_usp = usp;
|
||||
|
||||
next: if (*ptr1 == '?')
|
||||
{
|
||||
U_http_info.query = (const char*)(ptr1 += U_CONSTANT_SIZE("?queries"));
|
||||
|
||||
while (*++ptr1 != ' ') {}
|
||||
|
||||
U_http_info.query_len = (const char*)ptr1 - U_http_info.query;
|
||||
|
||||
U_INTERNAL_DUMP("query = %.*S", U_HTTP_QUERY_TO_TRACE)
|
||||
}
|
||||
|
||||
U_http_content_type_len = 0;
|
||||
|
||||
U_http_info.nResponseCode = HTTP_OK;
|
||||
|
||||
usp->runDynamicPage(0);
|
||||
|
||||
setDynamicResponse();
|
||||
|
||||
ext->clear();
|
||||
|
||||
(void) UServer_Base::pClientImage->writeResponse();
|
||||
|
||||
U_RETURN(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
void UHTTP::callInitForAllUSP()
|
||||
{
|
||||
U_TRACE_NO_PARAM(0+256, "UHTTP::callInitForAllUSP()")
|
||||
|
|
|
@ -183,9 +183,9 @@ static void test3(void)
|
|||
puts("");
|
||||
}
|
||||
|
||||
/*
|
||||
static void test4(void)
|
||||
{
|
||||
/*
|
||||
#if !defined(SOLARIS) && !defined(MACOSX)
|
||||
char bytes[7];
|
||||
char buf[20];
|
||||
|
@ -206,8 +206,8 @@ static void test4(void)
|
|||
result = 1;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
*/
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
@ -319,7 +319,5 @@ int main(int argc, char* argv[])
|
|||
rfg1();
|
||||
rfg2();
|
||||
|
||||
test4();
|
||||
|
||||
return (result != 0);
|
||||
}
|
||||
|
|
|
@ -28,17 +28,17 @@ export ORM_DRIVER ORM_OPTION UMEMPOOL
|
|||
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
#Running 15s test @ http://localhost:8080/plaintext
|
||||
# 4 threads and 256 connections
|
||||
# Thread Stats Avg Stdev Max +/- Stdev
|
||||
# Latency 1.00ms 220.28us 17.02ms 74.17%
|
||||
# Req/Sec 552.46k 33.92k 614.40k 54.19%
|
||||
# Latency Distribution
|
||||
# 50% 1.00ms
|
||||
# 75% 1.13ms
|
||||
# 90% 1.24ms
|
||||
# 99% 1.43ms
|
||||
# 31102816 requests in 14.97s, 3.74GB read
|
||||
#Requests/sec: 2077107.68
|
||||
#Transfer/sec: 255.53MB
|
||||
# Thread Stats Avg Stdev Max +/- Stdev
|
||||
# Latency 1.86ms 2.30ms 28.08ms 88.21%
|
||||
# Req/Sec 552.42k 200.56k 1.39M 68.22%
|
||||
# Latency Distribution
|
||||
# 50% 1.00ms
|
||||
# 75% 2.46ms
|
||||
# 90% 4.53ms
|
||||
# 99% 11.03ms
|
||||
# 30638208 requests in 14.99s, 3.68GB read
|
||||
#Requests/sec: 2044562.05
|
||||
#Transfer/sec: 251.53MB
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# JSON
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -49,16 +49,16 @@ export ORM_DRIVER ORM_OPTION UMEMPOOL
|
|||
#Running 15s test @ http://localhost:8080/json
|
||||
# 4 threads and 256 connections
|
||||
# Thread Stats Avg Stdev Max +/- Stdev
|
||||
# Latency 449.69us 236.81us 20.50ms 89.87%
|
||||
# Req/Sec 76.61k 5.88k 99.00k 54.11%
|
||||
# Latency 0.90ms 2.52ms 36.05ms 93.49%
|
||||
# Req/Sec 89.35k 47.88k 229.78k 65.55%
|
||||
# Latency Distribution
|
||||
# 50% 443.00us
|
||||
# 75% 562.00us
|
||||
# 90% 645.00us
|
||||
# 99% 823.00us
|
||||
# 4323309 requests in 15.00s, 614.33MB read
|
||||
#Requests/sec: 288235.65
|
||||
#Transfer/sec: 40.96MB
|
||||
# 50% 166.00us
|
||||
# 75% 408.00us
|
||||
# 90% 2.27ms
|
||||
# 99% 11.68ms
|
||||
# 4845404 requests in 15.00s, 688.52MB read
|
||||
#Requests/sec: 323059.07
|
||||
#Transfer/sec: 45.91MB
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# DB
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1494,20 +1494,11 @@ U_EXPORT main(int argc, char* argv[])
|
|||
|
||||
U_TRACE(5, "main(%d)", argc)
|
||||
|
||||
bool ok = u_isUTF8((const unsigned char*)U_CONSTANT_TO_PARAM("..M-^X@M-/..M-^X@1M-/..\xC3\xBC\x88\x01\x0BM-^X@M-/..M-^X@M-/..M-^X@M-/../winnt/system32/cmd.exe"));
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(ok, false)
|
||||
|
||||
UCrono crono;
|
||||
UString x(100U), y = U_STRING_FROM_CONSTANT("0.0000001"), z, z1, value = U_STRING_FROM_CONSTANT("0.0");
|
||||
|
||||
UString new_value(U_CAPACITY, U_CONSTANT_TO_PARAM("%.*s; %v"), U_STRING_TO_TRACE(y), value.rep);
|
||||
|
||||
value = new_value;
|
||||
|
||||
U_INTERNAL_DUMP("value(%u): = %.*S", value.size(), U_STRING_TO_TRACE(value))
|
||||
|
||||
U_ASSERT( value == U_STRING_FROM_CONSTANT("0.0000001; 0.0") )
|
||||
/*
|
||||
double val1 = U_STRING_FROM_CONSTANT("0").strtod();
|
||||
u__printf(1, U_CONSTANT_TO_PARAM("0 = %lf %g"), val1, val1);
|
||||
exit(0);
|
||||
*/
|
||||
|
||||
U_ASSERT( U_STRING_FROM_CONSTANT("0.0").strtod() == 0.0 )
|
||||
U_ASSERT( U_STRING_FROM_CONSTANT("1.0").strtod() == 1.0 )
|
||||
|
@ -1563,6 +1554,7 @@ U_EXPORT main(int argc, char* argv[])
|
|||
#endif
|
||||
|
||||
int i;
|
||||
UString x(100U), y, z;
|
||||
|
||||
for (i = -310; i < 310; ++i)
|
||||
{
|
||||
|
@ -1636,6 +1628,23 @@ U_EXPORT main(int argc, char* argv[])
|
|||
U_ASSERT( y == U_STRING_FROM_CONSTANT("10.30.1.0/24 10.1.0.1/16") )
|
||||
#endif
|
||||
|
||||
UCrono crono;
|
||||
UString z1, value = U_STRING_FROM_CONSTANT("0.0");
|
||||
|
||||
y = U_STRING_FROM_CONSTANT("0.0000001");
|
||||
|
||||
UString new_value(U_CAPACITY, U_CONSTANT_TO_PARAM("%.*s; %v"), U_STRING_TO_TRACE(y), value.rep);
|
||||
|
||||
value = new_value;
|
||||
|
||||
U_INTERNAL_DUMP("value(%u): = %.*S", value.size(), U_STRING_TO_TRACE(value))
|
||||
|
||||
U_ASSERT( value == U_STRING_FROM_CONSTANT("0.0000001; 0.0") )
|
||||
|
||||
bool ok = u_isUTF8((const unsigned char*)U_CONSTANT_TO_PARAM("..M-^X@M-/..M-^X@1M-/..\xC3\xBC\x88\x01\x0BM-^X@M-/..M-^X@M-/..M-^X@M-/../winnt/system32/cmd.exe"));
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(ok, false)
|
||||
|
||||
UString buffer(U_CAPACITY), encoded(U_CAPACITY);
|
||||
|
||||
z1 = UStringExt::prepareForEnvironmentVar(U_STRING_FROM_CONSTANT("MasqueradeDevice=eth0 'AuthServiceAddr=http://wifi-aaa2.comune.fi.it' FullPrivateNetwork=172.16.0.0/12 "
|
||||
|
|
Loading…
Reference in New Issue
Block a user