You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
The HTTP header check about the Basic authentication, and problem of the Base64 encoding. #407
The HTTP header check about the Basic authentication, and problem of the Base64 encoding.
I think that strncmp() (underline part) should be changed to
strncasecmp().
cups/auth.c
cupsDoAuthentication() function
...
/*
Nope, see if we should retry the current digest password...
*/
if (strncmp(http->fields[HTTP_FIELD_WWW_AUTHENTICATE], "Basic", 5) == 0 ||
~~~~~~~ <- should use strncasecmp() for necessary to connect with more equipment
http->digest_tries > 1 || !http->userpass[0])
{
/*
Nope - get a new password from the user... /
...
/
Got a password; encode it for the server...
*/
if (strncmp(http->fields[HTTP_FIELD_WWW_AUTHENTICATE], "Basic", 5) == 0)
~~~~~~~ <- should use strncasecmp() for necessary to connect with more equipment
{
/*
Basic authentication...
*/
cups/http.c
httpEncord64() function
This function may be wrong. Example, when "aono:aono" encodes using base64 algorithm, "YW9ubzphb25v" should be generated. However, this function generates "YW9ubzphb25v=".
As for the base64 encoding, please provide specific references in the appropriate RFCs to support your claim. We have no reports of problems with this code.
There is a following description in the RFC1341, 1521, and 2045.
5.2 Base64 Content-Transfer-Encoding
...
Special processing is performed if fewer than 24 bits are available at the end of the data being encoded. A full encoding quantum is always completed at the end of a body.
When fewer than 24 input bits are available in an input group, zero bits are added (on the right) to form an integral number of 6-bit groups. Output character positions which are not required to represent actual input data are set to the character "=". Since all base64
input is an integral number of octets, only the following cases can arise: (1) the final quantum of encoding input is an integral multiple of 24 bits; here, the final unit of encoded output will be an integral multiple of 4 characters with no "=" padding, (2) the final quantum of encoding input is exactly 8 bits; here, the final unit of encoded output will be two characters followed by two "=" padding characters, or (3) the final quantum of encoding input is exactly 16 bits; here, the final unit of encoded output will be three characters followed by one "=" padding character.
...
RFC2045
...
Because it is used only for padding at the end of the data, the
occurrence of any "=" characters may be taken as evidence that the
end of the data has been reached (without truncation in transit). No
such assurance is possible, however, when the number of octets transmitted was a multiple of three and no "=" characters are present.
...
Therefore, about httpEncode64() function, I think that the character string(such as "aono:aono") which divides by 3 multiples doesn't have '='.
However, because httpDecode64() function is fail safe, I think that it is good to become the implementing which ignores last '='. (I think that Apache is also same implementing.)
Activity
michaelrsweet commentedon Nov 17, 2003
CUPS.org User: mike
The strcasecmp change appears to be correct.
As for the base64 encoding, please provide specific references in the appropriate RFCs to support your claim. We have no reports of problems with this code.
michaelrsweet commentedon Nov 19, 2003
CUPS.org User: kawasima.rsk-kitami.grp.ricoh.co
There is a following description in the RFC1341, 1521, and 2045.
5.2 Base64 Content-Transfer-Encoding
...
Special processing is performed if fewer than 24 bits are available at the end of the data being encoded. A full encoding quantum is always completed at the end of a body.
When fewer than 24 input bits are available in an input group, zero bits are added (on the right) to form an integral number of 6-bit groups. Output character positions which are not required to represent actual input data are set to the character "=". Since all base64
input is an integral number of octets, only the following cases can arise: (1) the final quantum of encoding input is an integral multiple of 24 bits; here, the final unit of encoded output will be an integral multiple of 4 characters with no "=" padding, (2) the final quantum of encoding input is exactly 8 bits; here, the final unit of encoded output will be two characters followed by two "=" padding characters, or (3) the final quantum of encoding input is exactly 16 bits; here, the final unit of encoded output will be three characters followed by one "=" padding character.
...
RFC2045
...
Because it is used only for padding at the end of the data, the
occurrence of any "=" characters may be taken as evidence that the
end of the data has been reached (without truncation in transit). No
such assurance is possible, however, when the number of octets transmitted was a multiple of three and no "=" characters are present.
...
Therefore, about httpEncode64() function, I think that the character string(such as "aono:aono") which divides by 3 multiples doesn't have '='.
However, because httpDecode64() function is fail safe, I think that it is good to become the implementing which ignores last '='. (I think that Apache is also same implementing.)
michaelrsweet commentedon Nov 19, 2003
CUPS.org User: mike
I've updated both the strncasecmp stuff and the code that added the '=' to the end for strings that were a multiple of 3 chars.
michaelrsweet commentedon Nov 19, 2003
CUPS.org User: mike
Fixed in CVS - the anonymous CVS repository will be updated at midnight EST.