X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Fliblutil%2Fbase64.c;h=85eb0c2eabbb02f6eb68f319237178cb5b79cdfc;hb=56cba7f97cefe4eb0e61415e5c8cf10bfbe5f5e1;hp=6f4b88fe8d985c779261c44955c727b690d9c5c7;hpb=13bd786abf3248e39428a8edac67c27772cb8dc0;p=openldap diff --git a/libraries/liblutil/base64.c b/libraries/liblutil/base64.c index 6f4b88fe8d..85eb0c2eab 100644 --- a/libraries/liblutil/base64.c +++ b/libraries/liblutil/base64.c @@ -1,3 +1,8 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ /* * Modified by Kurt D. Zeilenga for inclusion into OpenLDAP */ @@ -46,9 +51,9 @@ #include "portable.h" -#include -#include - +#include +#include +#include #include /* include socket.h to get sys/types.h and/or winsock2.h */ @@ -56,8 +61,6 @@ #include "lutil.h" -#define Assert(Cond) if (!(Cond)) abort() - static const char Base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static const char Pad64 = '='; @@ -126,7 +129,7 @@ static const char Pad64 = '='; */ int -b64_ntop( +lutil_b64_ntop( u_char const *src, size_t srclength, char *target, @@ -147,10 +150,10 @@ b64_ntop( output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); output[3] = input[2] & 0x3f; - Assert(output[0] < 64); - Assert(output[1] < 64); - Assert(output[2] < 64); - Assert(output[3] < 64); + assert(output[0] < 64); + assert(output[1] < 64); + assert(output[2] < 64); + assert(output[3] < 64); if (datalength + 4 > targsize) return (-1); @@ -170,9 +173,9 @@ b64_ntop( output[0] = input[0] >> 2; output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); - Assert(output[0] < 64); - Assert(output[1] < 64); - Assert(output[2] < 64); + assert(output[0] < 64); + assert(output[1] < 64); + assert(output[2] < 64); if (datalength + 4 > targsize) return (-1); @@ -197,7 +200,7 @@ b64_ntop( */ int -b64_pton( +lutil_b64_pton( char const *src, u_char *target, size_t targsize) @@ -209,7 +212,7 @@ b64_pton( tarindex = 0; while ((ch = *src++) != '\0') { - if (isspace(ch)) /* Skip whitespace anywhere. */ + if (isascii(ch) && isspace(ch)) /* Skip whitespace anywhere. */ continue; if (ch == Pad64) @@ -279,7 +282,7 @@ b64_pton( case 2: /* Valid, means one byte of info */ /* Skip any number of spaces. */ for ((void)NULL; ch != '\0'; ch = *src++) - if (!isspace(ch)) + if (! (isascii(ch) && isspace(ch))) break; /* Make sure there is another trailing = sign. */ if (ch != Pad64) @@ -294,7 +297,7 @@ b64_pton( * whitespace after it? */ for ((void)NULL; ch != '\0'; ch = *src++) - if (!isspace(ch)) + if (! (isascii(ch) && isspace(ch))) return (-1); /*