diff options
| author | Riccardo Spagni <ric@spagni.net> | 2018-07-03 15:21:56 +0200 |
|---|---|---|
| committer | Riccardo Spagni <ric@spagni.net> | 2018-07-03 15:21:56 +0200 |
| commit | d1f102626c47bfea1f38d9012793f00933bb83eb (patch) | |
| tree | 27cf204753cf3ee80a7a4b917160c42965049950 /src/device/log.cpp | |
| parent | 82c39355ac0f4a583757cb476136edc42f443740 (diff) | |
| parent | 34de7bc267984340d0c6c0afcbb1069af2f81e6d (diff) | |
| download | monzero-core-d1f102626c47bfea1f38d9012793f00933bb83eb.tar.gz monzero-core-d1f102626c47bfea1f38d9012793f00933bb83eb.tar.xz monzero-core-d1f102626c47bfea1f38d9012793f00933bb83eb.zip | |
Merge pull request #4043
34de7bc2 device_ledger: fix buffer underflow on bad data from device (moneromooo-monero)
41e9cab4 device: misc cleanup (moneromooo-monero)
3b4dec2d device_ledger: fix potential buffer overflow from bad size calc (moneromooo-monero)
Diffstat (limited to 'src/device/log.cpp')
| -rw-r--r-- | src/device/log.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/device/log.cpp b/src/device/log.cpp index cbbcfc953..1707524fb 100644 --- a/src/device/log.cpp +++ b/src/device/log.cpp @@ -45,13 +45,13 @@ namespace hw { } } - void log_hexbuffer(std::string msg, const char* buff, size_t len) { + void log_hexbuffer(const std::string &msg, const char* buff, size_t len) { char logstr[1025]; buffer_to_str(logstr, sizeof(logstr), buff, len); MDEBUG(msg<< ": " << logstr); } - void log_message(std::string msg, std::string info ) { + void log_message(const std::string &msg, const std::string &info ) { MDEBUG(msg << ": " << info); } @@ -122,16 +122,18 @@ namespace hw { rct::keyV decrypt(const rct::keyV &keys) { rct::keyV x ; + x.reserve(keys.size()); for (unsigned int j = 0; j<keys.size(); j++) { x.push_back(decrypt(keys[j])); } return x; } - static void check(std::string msg, std::string info, const char *h, const char *d, int len, bool crypted) { + static void check(const std::string &msg, const std::string &info, const char *h, const char *d, size_t len, bool crypted) { char dd[32]; char logstr[128]; + CHECK_AND_ASSERT_THROW_MES(len <= sizeof(dd), "invalid len"); memmove(dd,d,len); if (crypted) { CHECK_AND_ASSERT_THROW_MES(len<=32, "encrypted data greater than 32"); @@ -149,11 +151,11 @@ namespace hw { } } - void check32(std::string msg, std::string info, const char *h, const char *d, bool crypted) { + void check32(const std::string &msg, const std::string &info, const char *h, const char *d, bool crypted) { check(msg, info, h, d, 32, crypted); } - void check8(std::string msg, std::string info, const char *h, const char *d, bool crypted) { + void check8(const std::string &msg, const std::string &info, const char *h, const char *d, bool crypted) { check(msg, info, h, d, 8, crypted); } #endif |
