Proof of Concept on Bugprone Narrowing Conversions: Base64

This commit is contained in:
Dev Bali 2019-10-07 12:02:41 -07:00
parent 8ba19cd7d1
commit cad6f881eb
3 changed files with 24 additions and 20 deletions

View file

@ -1,4 +1,5 @@
#pragma once
#ifndef base64_h
#define base64_h
#include <assert.h>
#include <stdio.h>
@ -30,10 +31,10 @@ public:
// input bytes processed, since the decoding will stop when there
// is not enough output buffer space.
int Decode(int len, const char* data, int* blen, char** buf);
void Encode(int len, const unsigned char* data, int* blen, char** buf);
size_t Decode(size_t len, const char* data, size_t* pblen, char** buf);
void Encode(size_t len, const unsigned char* data, size_t* blen, char** buf);
int Done(int* pblen, char** pbuf);
int Done(size_t* pblen, char** pbuf);
int HasData() const { return base64_group_next != 0; }
// True if an error has occurred.
@ -70,3 +71,5 @@ protected:
BroString* decode_base64(const BroString* s, const BroString* a = 0, Connection* conn = 0);
BroString* encode_base64(const BroString* s, const BroString* a = 0, Connection* conn = 0);
#endif /* base64_h */