mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 05:58:20 +00:00
Merge remote-tracking branch 'origin/topic/dev/bugrpone-narrowing-conversions-base64'
* origin/topic/dev/bugrpone-narrowing-conversions-base64: Proof of Concept on Bugprone Narrowing Conversions: Base64 I fixed a few bugs in this while merging; Decode now signals success or error (which did not work before). I removed the new variables in mime.cc and just switched more to size_t - the new variables introduced a bug because they shadowed the changes of the Decode call. GH-616
This commit is contained in:
commit
705210a035
5 changed files with 36 additions and 28 deletions
15
src/Base64.h
15
src/Base64.h
|
@ -1,8 +1,10 @@
|
|||
#pragma once
|
||||
#ifndef base64_h
|
||||
#define base64_h
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <utility>
|
||||
|
||||
#include "util.h"
|
||||
#include "BroString.h"
|
||||
|
@ -27,13 +29,12 @@ public:
|
|||
// an appropriate size will be new'd and *buf will point
|
||||
// to the buffer on return. *blen holds the length of
|
||||
// decoded data on return. The function returns the number of
|
||||
// input bytes processed, since the decoding will stop when there
|
||||
// is not enough output buffer space.
|
||||
// input bytes processed and a success flag.
|
||||
|
||||
int Decode(int len, const char* data, int* blen, char** buf);
|
||||
void Encode(int len, const unsigned char* data, int* blen, char** buf);
|
||||
std::pair<size_t, bool> 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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue