MCPcopy Create free account
hub / github.com/apache/httpd / ap_escape_errorlog_item

Function ap_escape_errorlog_item

server/util.c:2251–2312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2249}
2250
2251AP_DECLARE(apr_size_t) ap_escape_errorlog_item(char *dest, const char *source,
2252 apr_size_t buflen)
2253{
2254 unsigned char *d, *ep;
2255 const unsigned char *s;
2256
2257 if (!source || !buflen) { /* be safe */
2258 return 0;
2259 }
2260
2261 d = (unsigned char *)dest;
2262 s = (const unsigned char *)source;
2263 ep = d + buflen - 1;
2264
2265 for (; d < ep && *s; ++s) {
2266
2267 if (TEST_CHAR(*s, T_ESCAPE_LOGITEM)) {
2268 *d++ = '\\';
2269 if (d >= ep) {
2270 --d;
2271 break;
2272 }
2273
2274 switch(*s) {
2275 case '\b':
2276 *d++ = 'b';
2277 break;
2278 case '\n':
2279 *d++ = 'n';
2280 break;
2281 case '\r':
2282 *d++ = 'r';
2283 break;
2284 case '\t':
2285 *d++ = 't';
2286 break;
2287 case '\v':
2288 *d++ = 'v';
2289 break;
2290 case '\\':
2291 *d++ = *s;
2292 break;
2293 case '"': /* no need for this in error log */
2294 d[-1] = *s;
2295 break;
2296 default:
2297 if (d >= ep - 2) {
2298 ep = --d; /* break the for loop as well */
2299 break;
2300 }
2301 c2x(*s, 'x', d);
2302 d += 3;
2303 }
2304 }
2305 else {
2306 *d++ = *s;
2307 }
2308 }

Callers 3

log_table_entryFunction · 0.85
do_errorlog_defaultFunction · 0.85
do_errorlog_formatFunction · 0.85

Calls 1

c2xFunction · 0.70

Tested by

no test coverage detected