Commit e87a899b authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:purerosefallen/ygopro

parents 782ece7b 18ec5ff4
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define BASE64_H #define BASE64_H
#include <string> #include <string>
#include <cstring>
const char kBase64Alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" const char kBase64Alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz"
...@@ -60,7 +61,9 @@ class Base64 { ...@@ -60,7 +61,9 @@ class Base64 {
size_t encoded_length = EncodedLength(input_length); size_t encoded_length = EncodedLength(input_length);
if (out_length < encoded_length) return false; if (out_length < encoded_length + 1) return false;
std::memset(out, 0, out_length);
while (input_length--) { while (input_length--) {
a3[i++] = *input++; a3[i++] = *input++;
......
...@@ -322,7 +322,7 @@ int DeckManager::TypeCount(std::vector<code_pointer> list, unsigned int ctype) { ...@@ -322,7 +322,7 @@ int DeckManager::TypeCount(std::vector<code_pointer> list, unsigned int ctype) {
bool DeckManager::LoadDeckFromCode(Deck& deck, const char *code, int len) { bool DeckManager::LoadDeckFromCode(Deck& deck, const char *code, int len) {
char data[1024], *pdeck = data, *data_ = data; char data[1024], *pdeck = data, *data_ = data;
int decoded_len = Base64::DecodedLength(code, len); int decoded_len = Base64::DecodedLength(code, len);
if(decoded_len < 8 || !Base64::Decode(code, len, data_, decoded_len)) if(decoded_len > 1024 || decoded_len < 8 || !Base64::Decode(code, len, data_, decoded_len))
return false; return false;
int mainc = BufferIO::ReadInt32(pdeck); int mainc = BufferIO::ReadInt32(pdeck);
int sidec = BufferIO::ReadInt32(pdeck); int sidec = BufferIO::ReadInt32(pdeck);
...@@ -341,7 +341,7 @@ int DeckManager::SaveDeckToCode(Deck& deck, char* code) { ...@@ -341,7 +341,7 @@ int DeckManager::SaveDeckToCode(Deck& deck, char* code) {
BufferIO::WriteInt32(pdeck, deck.side[i]->first); BufferIO::WriteInt32(pdeck, deck.side[i]->first);
int len = pdeck - deckbuf; int len = pdeck - deckbuf;
int encoded_len = Base64::EncodedLength(len); int encoded_len = Base64::EncodedLength(len);
Base64::Encode(deckbuf, len, code, encoded_len); Base64::Encode(deckbuf, len, code, encoded_len+1);
return encoded_len; return encoded_len;
} }
bool DeckManager::CreateCategory(const wchar_t* name) { bool DeckManager::CreateCategory(const wchar_t* name) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment