X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Flib%2Fbase64.c;h=02e42639c711681d250ec6b1bf0f17e0c6705838;hb=d8628580f5e43ec26d4816ac521cf2b1675a129b;hp=dbfcbd60bf46ed99e0ce3e669881a0b89dd809ae;hpb=d4cdfcb0408560b741a6574e594962f65344e2e7;p=bacula%2Fbacula diff --git a/bacula/src/lib/base64.c b/bacula/src/lib/base64.c index dbfcbd60bf..02e42639c7 100644 --- a/bacula/src/lib/base64.c +++ b/bacula/src/lib/base64.c @@ -1,3 +1,30 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + 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., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of Kern Sibbald. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ /* * Generic base 64 input and output routines * @@ -5,24 +32,11 @@ * * Version $Id$ */ -/* - Copyright (C) 2000-2005 Kern Sibbald - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - version 2 as amended with additional clauses defined in the - file LICENSE in the main source directory. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - the file LICENSE for additional details. - - */ #include "bacula.h" + #ifdef TEST_MODE #include #endif @@ -126,11 +140,14 @@ from_base64(intmax_t *value, char *where) * Encode binary data in bin of len bytes into * buf as base64 characters. * + * If compatible is true, the bin_to_base64 routine will be compatible + * with what the rest of the world uses. + * * Returns: the number of characters stored not * including the EOS */ int -bin_to_base64(char *buf, char *bin, int len) +bin_to_base64(char *buf, int buflen, char *bin, int binlen, int compatible) { uint32_t reg, save, mask; int rem, i; @@ -138,24 +155,32 @@ bin_to_base64(char *buf, char *bin, int len) reg = 0; rem = 0; - for (i=0; i>= (rem - 6); - buf[j++] = base64_digits[reg & (uint32_t)0x3F]; + if (j < buflen) { + buf[j++] = base64_digits[reg & 0x3F]; + } reg = save; rem -= 6; } - if (rem) { - mask = 1; - for (i=1; i