X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Faddagent%2Fb64.c;h=45ecb49e493caf0cfe94037e0f435a14854e205c;hp=00c0d0538240983dc4d331183613a3f006bdafda;hb=6ef2f786c6c8ead94841b5f93baf9f43421f08c8;hpb=301048b51990573e58a30dc4a5bb4ec285cad554 diff --git a/src/addagent/b64.c b/src/addagent/b64.c index 00c0d05..45ecb49 100755 --- a/src/addagent/b64.c +++ b/src/addagent/b64.c @@ -1,4 +1,5 @@ -/* @(#) $Id$ */ +/* @(#) $Id: ./src/addagent/b64.c, 2011/09/08 dcid Exp $ + */ /* * Copyright (C), 2000-2004 by the monit project group. * All Rights Reserved. @@ -12,7 +13,7 @@ * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -35,7 +36,7 @@ static unsigned char decode(char c); /** - * Implementation of base64 encoding/decoding. + * Implementation of base64 encoding/decoding. * * @author Jan-Henrik Haukeland, * @@ -67,7 +68,7 @@ char *encode_base64(int size, char *src) { out = (char *)calloc(sizeof(char), size*4/3+4); if(!out) return NULL; - + p = out; for(i = 0; i < size; i+=3) { @@ -113,45 +114,45 @@ char *encode_base64(int size, char *src) { * 'dest'. The dest buffer is NUL terminated. * Return NULL in case of error */ -char *decode_base64(const char *src) +char *decode_base64(const char *src) { - if(src && *src) + if(src && *src) { char *dest; unsigned char *p; int k, l = strlen(src)+1; unsigned char *buf; - + /* The size of the dest will always be less than * the source */ dest = (char *)calloc(sizeof(char), l + 13); if(!dest) return(NULL); - + p = (unsigned char *)dest; - + buf = malloc(l); if(!buf) return(NULL); /* Ignore non base64 chars as per the POSIX standard */ - for(k=0, l=0; src[k]; k++) + for(k=0, l=0; src[k]; k++) { - if(is_base64(src[k])) + if(is_base64(src[k])) { buf[l++]= src[k]; } - } + } - for(k=0; k