netutils/base64: correct the buffer type
This commit is contained in:
parent
9968461c2b
commit
52abe148ce
@ -35,17 +35,17 @@
|
|||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS''
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
* SUCH DAMAGE.
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -100,17 +100,19 @@ static FAR const char *base64_tab(bool websafe)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static FAR char *_base64_encode(FAR const char *src, size_t len,
|
static FAR unsigned char *_base64_encode(FAR const unsigned char *src,
|
||||||
FAR char *dst, FAR size_t *out_len,
|
size_t len,
|
||||||
bool websafe)
|
FAR unsigned char *dst,
|
||||||
|
FAR size_t *out_len,
|
||||||
|
bool websafe)
|
||||||
{
|
{
|
||||||
FAR char *out;
|
FAR unsigned char *out;
|
||||||
FAR char *pos;
|
FAR unsigned char *pos;
|
||||||
FAR const char *end;
|
FAR const unsigned char *end;
|
||||||
FAR const char *in;
|
FAR const unsigned char *in;
|
||||||
FAR const char *base64_table;
|
FAR const char *base64_table;
|
||||||
size_t olen;
|
|
||||||
char ch = '=';
|
char ch = '=';
|
||||||
|
size_t olen;
|
||||||
|
|
||||||
if (websafe)
|
if (websafe)
|
||||||
{
|
{
|
||||||
@ -190,17 +192,18 @@ static FAR char *_base64_encode(FAR const char *src, size_t len,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static char *_base64_decode(FAR const char *src, size_t len, FAR char *dst,
|
static unsigned char *_base64_decode(FAR const unsigned char *src,
|
||||||
FAR size_t *out_len, bool websafe)
|
size_t len, FAR unsigned char *dst,
|
||||||
|
FAR size_t *out_len, bool websafe)
|
||||||
{
|
{
|
||||||
FAR char *out;
|
FAR unsigned char *out;
|
||||||
FAR char *pos;
|
FAR unsigned char *pos;
|
||||||
FAR char block[4];
|
FAR unsigned char block[4];
|
||||||
FAR char *tmp;
|
|
||||||
FAR const char *base64_table;
|
FAR const char *base64_table;
|
||||||
|
char ch = '=';
|
||||||
|
FAR char *tmp;
|
||||||
size_t count;
|
size_t count;
|
||||||
size_t i;
|
size_t i;
|
||||||
char ch = '=';
|
|
||||||
|
|
||||||
if (websafe)
|
if (websafe)
|
||||||
{
|
{
|
||||||
@ -232,7 +235,7 @@ static char *_base64_decode(FAR const char *src, size_t len, FAR char *dst,
|
|||||||
if (count == 4)
|
if (count == 4)
|
||||||
{
|
{
|
||||||
*pos++ = (block[0] << 2) | (block[1] >> 4);
|
*pos++ = (block[0] << 2) | (block[1] >> 4);
|
||||||
if (src[i-1] == ch)
|
if (src[i - 1] == ch)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user