if (_cups_debug_fd < 0 || _cups_debug_level < 6)
return;
- DEBUG_printf(("6%s: %d bytes:", prefix, bytes));
+ DEBUG_printf(("9%s: %d bytes:", prefix, bytes));
- snprintf(line, sizeof(line), "6%s: ", prefix);
+ snprintf(line, sizeof(line), "9%s: ", prefix);
start = line + strlen(line);
for (i = 0; i < bytes; i += 16)
ssize_t bytes; /* Bytes read */
- DEBUG_printf(("http_read(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
+ DEBUG_printf(("7http_read(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
if (!http->blocking || http->timeout_value > 0.0)
{
if (http->timeout_cb && (*http->timeout_cb)(http, http->timeout_data))
continue;
- DEBUG_puts("2http_read: Timeout.");
+ DEBUG_puts("8http_read: Timeout.");
return (0);
}
}
- DEBUG_printf(("2http_read: Reading %d bytes into buffer.", (int)length));
+ DEBUG_printf(("8http_read: Reading %d bytes into buffer.", (int)length));
do
{
}
}
#else
- DEBUG_printf(("2http_read: %s", strerror(errno)));
+ DEBUG_printf(("8http_read: %s", strerror(errno)));
if (errno == EWOULDBLOCK || errno == EAGAIN)
{
}
while (bytes < 0);
- DEBUG_printf(("2http_read: Read " CUPS_LLFMT " bytes into buffer.",
- CUPS_LLCAST bytes));
+ DEBUG_printf(("8http_read: Read " CUPS_LLFMT " bytes into buffer.", CUPS_LLCAST bytes));
#ifdef DEBUG
if (bytes > 0)
http_debug_hex("http_read", buffer, (int)bytes);
ssize_t bytes; /* Bytes read */
- DEBUG_printf(("http_read_buffered(http=%p, buffer=%p, length=" CUPS_LLFMT ") used=%d", (void *)http, (void *)buffer, CUPS_LLCAST length, http->used));
+ DEBUG_printf(("7http_read_buffered(http=%p, buffer=%p, length=" CUPS_LLFMT ") used=%d", (void *)http, (void *)buffer, CUPS_LLCAST length, http->used));
if (http->used > 0)
{
else
bytes = (ssize_t)length;
- DEBUG_printf(("2http_read: Grabbing %d bytes from input buffer.",
+ DEBUG_printf(("8http_read: Grabbing %d bytes from input buffer.",
(int)bytes));
memcpy(buffer, http->buffer, (size_t)bytes);
char *buffer, /* I - Buffer */
size_t length) /* I - Maximum bytes to read */
{
- DEBUG_printf(("http_read_chunk(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
+ DEBUG_printf(("7http_read_chunk(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
if (http->data_remaining <= 0)
{
if (!httpGets(len, sizeof(len), http))
{
- DEBUG_puts("1http_read_chunk: Could not get chunk length.");
+ DEBUG_puts("8http_read_chunk: Could not get chunk length.");
return (0);
}
if (!len[0])
{
- DEBUG_puts("1http_read_chunk: Blank chunk length, trying again...");
+ DEBUG_puts("8http_read_chunk: Blank chunk length, trying again...");
if (!httpGets(len, sizeof(len), http))
{
- DEBUG_puts("1http_read_chunk: Could not get chunk length.");
+ DEBUG_puts("8http_read_chunk: Could not get chunk length.");
return (0);
}
}
if (http->data_remaining < 0)
{
- DEBUG_printf(("1http_read_chunk: Negative chunk length \"%s\" ("
+ DEBUG_printf(("8http_read_chunk: Negative chunk length \"%s\" ("
CUPS_LLFMT ")", len, CUPS_LLCAST http->data_remaining));
return (0);
}
- DEBUG_printf(("2http_read_chunk: Got chunk length \"%s\" (" CUPS_LLFMT ")",
+ DEBUG_printf(("8http_read_chunk: Got chunk length \"%s\" (" CUPS_LLFMT ")",
len, CUPS_LLCAST http->data_remaining));
if (http->data_remaining == 0)
}
}
- DEBUG_printf(("2http_read_chunk: data_remaining=" CUPS_LLFMT,
+ DEBUG_printf(("8http_read_chunk: data_remaining=" CUPS_LLFMT,
CUPS_LLCAST http->data_remaining));
if (http->data_remaining <= 0)
off_t remaining; /* Remainder */
- DEBUG_printf(("http_set_length(http=%p) mode=%d state=%s", (void *)http, http->mode, httpStateString(http->state)));
+ DEBUG_printf(("4http_set_length(http=%p) mode=%d state=%s", (void *)http, http->mode, httpStateString(http->state)));
if ((remaining = httpGetLength2(http)) >= 0)
{
http->state != HTTP_STATE_POST &&
http->state != HTTP_STATE_POST_SEND)
{
- DEBUG_puts("1http_set_length: Not setting data_encoding/remaining.");
+ DEBUG_puts("5http_set_length: Not setting data_encoding/remaining.");
return (remaining);
}
if (!_cups_strcasecmp(httpGetField(http, HTTP_FIELD_TRANSFER_ENCODING), "chunked"))
{
- DEBUG_puts("1http_set_length: Setting data_encoding to "
- "HTTP_ENCODING_CHUNKED.");
+ DEBUG_puts("5http_set_length: Setting data_encoding to HTTP_ENCODING_CHUNKED.");
http->data_encoding = HTTP_ENCODING_CHUNKED;
}
else
{
- DEBUG_puts("1http_set_length: Setting data_encoding to "
- "HTTP_ENCODING_LENGTH.");
+ DEBUG_puts("5http_set_length: Setting data_encoding to HTTP_ENCODING_LENGTH.");
http->data_encoding = HTTP_ENCODING_LENGTH;
}
- DEBUG_printf(("1http_set_length: Setting data_remaining to " CUPS_LLFMT ".",
- CUPS_LLCAST remaining));
+ DEBUG_printf(("5http_set_length: Setting data_remaining to " CUPS_LLFMT ".", CUPS_LLCAST remaining));
http->data_remaining = remaining;
if (remaining <= INT_MAX)
http_t myhttp; /* Local copy of HTTP data */
- DEBUG_printf(("7http_tls_upgrade(%p)", (void *)http));
+ DEBUG_printf(("4http_tls_upgrade(%p)", (void *)http));
/*
* Flush the connection to make sure any previous "Upgrade" message
* Server does not support HTTP upgrade...
*/
- DEBUG_puts("8http_tls_upgrade: Server does not support HTTP upgrade!");
+ DEBUG_puts("5http_tls_upgrade: Server does not support HTTP upgrade!");
_cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, _("Encryption is not supported."), 1);
httpAddrClose(NULL, http->fd);
bytes; /* Bytes sent */
- DEBUG_printf(("2http_write(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
+ DEBUG_printf(("7http_write(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
http->error = 0;
tbytes = 0;
while (length > 0)
{
- DEBUG_printf(("3http_write: About to write %d bytes.", (int)length));
+ DEBUG_printf(("8http_write: About to write %d bytes.", (int)length));
if (http->timeout_value > 0.0)
{
#endif /* HAVE_TLS */
bytes = send(http->fd, buffer, length, 0);
- DEBUG_printf(("3http_write: Write of " CUPS_LLFMT " bytes returned "
- CUPS_LLFMT ".", CUPS_LLCAST length, CUPS_LLCAST bytes));
+ DEBUG_printf(("8http_write: Write of " CUPS_LLFMT " bytes returned " CUPS_LLFMT ".", CUPS_LLCAST length, CUPS_LLCAST bytes));
if (bytes < 0)
{
}
#endif /* _WIN32 */
- DEBUG_printf(("3http_write: error writing data (%s).",
- strerror(http->error)));
+ DEBUG_printf(("8http_write: error writing data (%s).", strerror(http->error)));
return (-1);
}
http_debug_hex("http_write", buffer - tbytes, (int)tbytes);
#endif /* DEBUG */
- DEBUG_printf(("3http_write: Returning " CUPS_LLFMT ".", CUPS_LLCAST tbytes));
+ DEBUG_printf(("8http_write: Returning " CUPS_LLFMT ".", CUPS_LLCAST tbytes));
return (tbytes);
}
error = SSLRead(http->tls, buf, (size_t)len, &processed);
- DEBUG_printf(("6_httpTLSRead: error=%d, processed=%d", (int)error,
- (int)processed));
+ DEBUG_printf(("5_httpTLSRead: error=%d, processed=%d", (int)error, (int)processed));
switch (error)
{
case 0 :
{
error = SSLSetSessionOption(http->tls,
kSSLSessionOptionBreakOnCertRequested, true);
- DEBUG_printf(("4_httpTLSStart: kSSLSessionOptionBreakOnCertRequested, "
- "error=%d", (int)error));
+ DEBUG_printf(("4_httpTLSStart: kSSLSessionOptionBreakOnCertRequested, error=%d", (int)error));
}
else
{
error = http_cdsa_set_credentials(http);
- DEBUG_printf(("4_httpTLSStart: http_cdsa_set_credentials, error=%d",
- (int)error));
+ DEBUG_printf(("4_httpTLSStart: http_cdsa_set_credentials, error=%d", (int)error));
}
}
else if (!error)
httpFreeCredentials(credentials);
}
- DEBUG_printf(("4_httpTLSStart: Server certificate callback "
- "returned %d.", (int)error));
+ DEBUG_printf(("4_httpTLSStart: Server certificate callback returned %d.", (int)error));
}
break;
error = (cg->client_cert_cb)(http, http->tls, names,
cg->client_cert_data);
- DEBUG_printf(("4_httpTLSStart: Client certificate callback "
- "returned %d.", (int)error));
+ DEBUG_printf(("4_httpTLSStart: Client certificate callback returned %d.", (int)error));
}
httpFreeCredentials(names);
break;
case errSSLUnknownRootCert :
- message = _("Unable to establish a secure connection to host "
- "(untrusted certificate).");
+ message = _("Unable to establish a secure connection to host (untrusted certificate).");
break;
case errSSLNoRootCert :
- message = _("Unable to establish a secure connection to host "
- "(self-signed certificate).");
+ message = _("Unable to establish a secure connection to host (self-signed certificate).");
break;
case errSSLCertExpired :
- message = _("Unable to establish a secure connection to host "
- "(expired certificate).");
+ message = _("Unable to establish a secure connection to host (expired certificate).");
break;
case errSSLCertNotYetValid :
- message = _("Unable to establish a secure connection to host "
- "(certificate not yet valid).");
+ message = _("Unable to establish a secure connection to host (certificate not yet valid).");
break;
case errSSLHostNameMismatch :
- message = _("Unable to establish a secure connection to host "
- "(host name mismatch).");
+ message = _("Unable to establish a secure connection to host (host name mismatch).");
break;
case errSSLXCertChainInvalid :
- message = _("Unable to establish a secure connection to host "
- "(certificate chain invalid).");
+ message = _("Unable to establish a secure connection to host (certificate chain invalid).");
break;
case errSSLConnectionRefused :
- message = _("Unable to establish a secure connection to host "
- "(peer dropped connection before responding).");
+ message = _("Unable to establish a secure connection to host (peer dropped connection before responding).");
break;
default :
size_t processed; /* Number of bytes processed */
- DEBUG_printf(("2_httpTLSWrite(http=%p, buf=%p, len=%d)", (void *)http, (void *)buf, len));
+ DEBUG_printf(("4_httpTLSWrite(http=%p, buf=%p, len=%d)", (void *)http, (void *)buf, len));
error = SSLWrite(http->tls, buf, (size_t)len, &processed);
break;
}
- DEBUG_printf(("3_httpTLSWrite: Returning %d.", (int)result));
+ DEBUG_printf(("5_httpTLSWrite: Returning %d.", (int)result));
return ((int)result);
}
ssize_t bytes; /* Bytes read */
- DEBUG_printf(("6http_gnutls_read(ptr=%p, data=%p, length=%d)", ptr, data, (int)length));
+ DEBUG_printf(("5http_gnutls_read(ptr=%p, data=%p, length=%d)", ptr, data, (int)length));
http = (http_t *)ptr;
}
bytes = recv(http->fd, data, length, 0);
- DEBUG_printf(("6http_gnutls_read: bytes=%d", (int)bytes));
+ DEBUG_printf(("5http_gnutls_read: bytes=%d", (int)bytes));
return (bytes);
}
ssize_t bytes; /* Bytes written */
- DEBUG_printf(("6http_gnutls_write(ptr=%p, data=%p, length=%d)", ptr, data,
+ DEBUG_printf(("5http_gnutls_write(ptr=%p, data=%p, length=%d)", ptr, data,
(int)length));
bytes = send(((http_t *)ptr)->fd, data, length, 0);
- DEBUG_printf(("http_gnutls_write: bytes=%d", (int)bytes));
+ DEBUG_printf(("5http_gnutls_write: bytes=%d", (int)bytes));
return (bytes);
}
ssize_t result; /* Return value */
- DEBUG_printf(("2http_write_ssl(http=%p, buf=%p, len=%d)", http, buf, len));
+ DEBUG_printf(("5_httpTLSWrite(http=%p, buf=%p, len=%d)", http, buf, len));
result = gnutls_record_send(http->tls, buf, (size_t)len);
result = -1;
}
- DEBUG_printf(("3http_write_ssl: Returning %d.", (int)result));
+ DEBUG_printf(("5_httpTLSWrite: Returning %d.", (int)result));
return ((int)result);
}
if (sspi->decryptBufferLength >= 262144)
{
WSASetLastError(E_OUTOFMEMORY);
- DEBUG_puts("_httpTLSRead: Decryption buffer too large (>256k)");
+ DEBUG_puts("5_httpTLSRead: Decryption buffer too large (>256k)");
return (-1);
}
if ((temp = realloc(sspi->decryptBuffer, sspi->decryptBufferLength + 4096)) == NULL)
{
- DEBUG_printf(("_httpTLSRead: Unable to allocate %d byte decryption buffer.", sspi->decryptBufferLength + 4096));
+ DEBUG_printf(("5_httpTLSRead: Unable to allocate %d byte decryption buffer.", sspi->decryptBufferLength + 4096));
WSASetLastError(E_OUTOFMEMORY);
return (-1);
}
sspi->decryptBufferLength += 4096;
sspi->decryptBuffer = temp;
- DEBUG_printf(("_httpTLSRead: Resized decryption buffer to %d bytes.", sspi->decryptBufferLength));
+ DEBUG_printf(("5_httpTLSRead: Resized decryption buffer to %d bytes.", sspi->decryptBufferLength));
}
buffers[0].pvBuffer = sspi->decryptBuffer;
if ((temp = realloc(sspi->readBuffer, sspi->readBufferUsed + bytesToSave)) == NULL)
{
- DEBUG_printf(("_httpTLSRead: Unable to allocate %d bytes.", sspi->readBufferUsed + bytesToSave));
+ DEBUG_printf(("5_httpTLSRead: Unable to allocate %d bytes.", sspi->readBufferUsed + bytesToSave));
WSASetLastError(E_OUTOFMEMORY);
return (-1);
}
}
else
{
- DEBUG_puts("_httpTLSRead: Unable to find data buffer.");
+ DEBUG_puts("5_httpTLSRead: Unable to find data buffer.");
WSASetLastError(WSASYSCALLFAILURE);
return (-1);
}
if ((cbData == SOCKET_ERROR) || (cbData == 0))
{
status = WSAGetLastError();
- DEBUG_printf(("_httpTLSStop: sending close notify failed: %d", status));
+ DEBUG_printf(("4_httpTLSStop: sending close notify failed: %d", status));
}
else
{
}
else
{
- DEBUG_printf(("_httpTLSStop: AcceptSecurityContext failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), status)));
+ DEBUG_printf(("4_httpTLSStop: AcceptSecurityContext failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), status)));
}
}
else
{
- DEBUG_printf(("_httpTLSStop: ApplyControlToken failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), status)));
+ DEBUG_printf(("4_httpTLSStop: ApplyControlToken failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), status)));
}
}
if ((temp = (BYTE *)realloc(sspi->writeBuffer, bufferLen)) == NULL)
{
- DEBUG_printf(("_httpTLSWrite: Unable to allocate buffer of %d bytes.", bufferLen));
+ DEBUG_printf(("5_httpTLSWrite: Unable to allocate buffer of %d bytes.", bufferLen));
WSASetLastError(E_OUTOFMEMORY);
return (-1);
}
if (FAILED(scRet))
{
- DEBUG_printf(("_httpTLSWrite: EncryptMessage failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), scRet)));
+ DEBUG_printf(("5_httpTLSWrite: EncryptMessage failed: %s", http_sspi_strerror(sspi->error, sizeof(sspi->error), scRet)));
WSASetLastError(WSASYSCALLFAILURE);
return (-1);
}
if (num <= 0)
{
- DEBUG_printf(("_httpTLSWrite: send failed: %ld", WSAGetLastError()));
+ DEBUG_printf(("5_httpTLSWrite: send failed: %ld", WSAGetLastError()));
return (num);
}
{
status = GetLastError();
- DEBUG_printf(("CertGetCertificateChain returned: %s", http_sspi_strerror(error, sizeof(error), status)));
+ DEBUG_printf(("5http_sspi_verify: CertGetCertificateChain returned: %s", http_sspi_strerror(error, sizeof(error), status)));
LocalFree(commonNameUnicode);
return (status);
{
status = GetLastError();
- DEBUG_printf(("CertVerifyCertificateChainPolicy returned %s", http_sspi_strerror(error, sizeof(error), status)));
+ DEBUG_printf(("5http_sspi_verify: CertVerifyCertificateChainPolicy returned %s", http_sspi_strerror(error, sizeof(error), status)));
}
else if (policyStatus.dwError)
status = policyStatus.dwError;