MCPcopy Create free account
hub / github.com/OpenPrinting/cups / _httpTLSRead

Function _httpTLSRead

cups/tls-sspi.c:698–905  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

696 */
697
698int /* O - Bytes read */
699_httpTLSRead(http_t *http, /* I - HTTP connection */
700 char *buf, /* I - Buffer to store data */
701 int len) /* I - Length of buffer */
702{
703 int i; /* Looping var */
704 _http_sspi_t *sspi = http->tls; /* SSPI data */
705 SecBufferDesc message; /* Array of SecBuffer struct */
706 SecBuffer buffers[4] = { 0 }; /* Security package buffer */
707 int num = 0; /* Return value */
708 PSecBuffer pDataBuffer; /* Data buffer */
709 PSecBuffer pExtraBuffer; /* Excess data buffer */
710 SECURITY_STATUS scRet; /* SSPI status */
711
712
713 DEBUG_printf(("4_httpTLSRead(http=%p, buf=%p, len=%d)", http, buf, len));
714
715 /*
716 * If there are bytes that have already been decrypted and have not yet been
717 * read, return those...
718 */
719
720 if (sspi->readBufferUsed > 0)
721 {
722 int bytesToCopy = min(sspi->readBufferUsed, len);
723 /* Number of bytes to copy */
724
725 memcpy(buf, sspi->readBuffer, bytesToCopy);
726 sspi->readBufferUsed -= bytesToCopy;
727
728 if (sspi->readBufferUsed > 0)
729 memmove(sspi->readBuffer, sspi->readBuffer + bytesToCopy, sspi->readBufferUsed);
730
731 DEBUG_printf(("5_httpTLSRead: Returning %d bytes previously decrypted.", bytesToCopy));
732
733 return (bytesToCopy);
734 }
735
736 /*
737 * Initialize security buffer structs
738 */
739
740 message.ulVersion = SECBUFFER_VERSION;
741 message.cBuffers = 4;
742 message.pBuffers = buffers;
743
744 do
745 {
746 /*
747 * If there is not enough space in the buffer, then increase its size...
748 */
749
750 if (sspi->decryptBufferLength <= sspi->decryptBufferUsed)
751 {
752 BYTE *temp; /* New buffer */
753
754 if (sspi->decryptBufferLength >= 262144)
755 {

Callers 1

http_readFunction · 0.70

Calls 4

http_sspi_set_errorFunction · 0.85
http_sspi_strerrorFunction · 0.85
_cupsSetHTTPErrorFunction · 0.85
_cupsSetErrorFunction · 0.85

Tested by

no test coverage detected