Index: cups/http.c =================================================================== --- cups/http.c (revision 7434) +++ cups/http.c (working copy) @@ -2527,8 +2527,7 @@ const char *uri) /* I - URI */ { int i; /* Looping var */ - char *ptr, /* Pointer in buffer */ - buf[1024]; /* Encoded URI buffer */ + char buf[1024]; /* Encoded URI buffer */ static const char * const codes[] = { /* Request code strings */ NULL, @@ -2566,21 +2565,8 @@ * Encode the URI as needed... */ - for (ptr = buf; *uri != '\0' && ptr < (buf + sizeof(buf) - 1); uri ++) - if (*uri <= ' ' || *uri >= 127) - { - if (ptr < (buf + sizeof(buf) - 1)) - *ptr ++ = '%'; - if (ptr < (buf + sizeof(buf) - 1)) - *ptr ++ = hex[(*uri >> 4) & 15]; - if (ptr < (buf + sizeof(buf) - 1)) - *ptr ++ = hex[*uri & 15]; - } - else - *ptr ++ = *uri; + _httpEncodeURI(buf, uri, sizeof(buf)); - *ptr = '\0'; - /* * See if we had an error the last time around; if so, reconnect... */ Index: cups/http-support.c =================================================================== --- cups/http-support.c (revision 7434) +++ cups/http-support.c (working copy) @@ -36,6 +36,7 @@ * httpStatus() - Return a short string describing a HTTP status code. * _cups_hstrerror() - hstrerror() emulation function for Solaris and * others... + * _httpEncodeURI() - Percent-encode a HTTP request URI. * http_copy_decode() - Copy and decode a URI. * http_copy_encode() - Copy and encode a URI. */ @@ -1204,6 +1205,20 @@ /* + * '_httpEncodeURI()' - Percent-encode a HTTP request URI. + */ + +char * /* O - Encoded URI */ +_httpEncodeURI(char *dst, /* I - Destination buffer */ + const char *src, /* I - Source URI */ + size_t dstsize) /* I - Size of destination buffer */ +{ + http_copy_encode(dst, src, dst + dstsize - 1, NULL, NULL, 1); + return (dst); +} + + +/* * 'http_copy_decode()' - Copy and decode a URI. */ @@ -1311,6 +1326,8 @@ *dst++ = *src++; } + *dst = '\0'; + if (*src) return (NULL); else Index: cups/http-private.h =================================================================== --- cups/http-private.h (revision 7434) +++ cups/http-private.h (working copy) @@ -257,6 +257,12 @@ # endif /* HAVE_GETIFADDRS */ # endif /* !WIN32 */ +/* + * Common URI encoding function... + */ + +extern char *_httpEncodeURI(char *dst, const char *src, size_t dstsize); + #endif /* !_CUPS_HTTP_PRIVATE_H_ */ /* Index: cups/libcups.exp =================================================================== --- cups/libcups.exp (revision 7434) +++ cups/libcups.exp (working copy) @@ -26,6 +26,7 @@ __cupsStrFree __cupsStrScand __cupsStrStatistics +__httpEncodeURI __httpReadCDSA __httpWriteCDSA __ippAddAttr Index: scheduler/log.c =================================================================== --- scheduler/log.c (revision 7434) +++ scheduler/log.c (working copy) @@ -65,6 +65,13 @@ }; + /* + * Make sure we have a valid time... + */ + + if (!t) + t = time(NULL); + if (t != last_time) { last_time = t; @@ -174,7 +181,7 @@ 'd' }; #ifdef HAVE_VSYSLOG - static const int syslevels[] = /* SYSLOG levels... */ + static const int syslevels[] = /* SYSLOG levels... */ { 0, LOG_EMERG, @@ -188,8 +195,8 @@ LOG_DEBUG }; #endif /* HAVE_VSYSLOG */ - static int linesize = 0; /* Size of line for output file */ - static char *line = NULL; /* Line for output file */ + static int linesize = 0; /* Size of line for output file */ + static char *line = NULL; /* Line for output file */ /* @@ -388,6 +395,7 @@ cupsdLogRequest(cupsd_client_t *con, /* I - Request to log */ http_status_t code) /* I - Response code */ { + char temp[2048]; /* Temporary string for URI */ static const char * const states[] = /* HTTP client states... */ { "WAITING", @@ -417,7 +425,7 @@ syslog(LOG_INFO, "REQUEST %s - %s \"%s %s HTTP/%d.%d\" %d " CUPS_LLFMT " %s %s\n", con->http.hostname, con->username[0] != '\0' ? con->username : "-", - states[con->operation], con->uri, + states[con->operation], _httpEncodeURI(temp, con->uri, sizeof(temp)), con->http.version / 100, con->http.version % 100, code, CUPS_LLCAST con->bytes, con->request ? @@ -443,7 +451,8 @@ cupsFilePrintf(AccessFile, "%s - %s %s \"%s %s HTTP/%d.%d\" %d " CUPS_LLFMT " %s %s\n", con->http.hostname, con->username[0] != '\0' ? con->username : "-", - cupsdGetDateTime(con->start), states[con->operation], con->uri, + cupsdGetDateTime(con->start), states[con->operation], + _httpEncodeURI(temp, con->uri, sizeof(temp)), con->http.version / 100, con->http.version % 100, code, CUPS_LLCAST con->bytes, con->request ?