mirror of https://github.com/YosysHQ/yosys.git
fixing incorrect buffer size allocation, and unsafe integer size type
This commit is contained in:
parent
87333f3ae2
commit
76cc2bf7b4
|
@ -13,6 +13,8 @@
|
||||||
-- Bruce Guenter <bruce@untroubled.org>
|
-- Bruce Guenter <bruce@untroubled.org>
|
||||||
Translation to simpler C++ Code
|
Translation to simpler C++ Code
|
||||||
-- Volker Grabsch <vog@notjusthosting.com>
|
-- Volker Grabsch <vog@notjusthosting.com>
|
||||||
|
Fixing bugs and improving style
|
||||||
|
-- Eugene Hopkinson <slowriot at voxelstorm dot com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sha1.h"
|
#include "sha1.h"
|
||||||
|
@ -241,7 +243,7 @@ void SHA1::transform(uint32 block[BLOCK_BYTES])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SHA1::buffer_to_block(const std::string &buffer, uint32 block[BLOCK_BYTES])
|
void SHA1::buffer_to_block(const std::string &buffer, uint32 block[BLOCK_INTS])
|
||||||
{
|
{
|
||||||
/* Convert the std::string (byte buffer) to a uint32 array (MSB) */
|
/* Convert the std::string (byte buffer) to a uint32 array (MSB) */
|
||||||
for (unsigned int i = 0; i < BLOCK_INTS; i++)
|
for (unsigned int i = 0; i < BLOCK_INTS; i++)
|
||||||
|
@ -254,7 +256,7 @@ void SHA1::buffer_to_block(const std::string &buffer, uint32 block[BLOCK_BYTES])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SHA1::read(std::istream &is, std::string &s, int max)
|
void SHA1::read(std::istream &is, std::string &s, size_t max)
|
||||||
{
|
{
|
||||||
char* sbuf = new char[max];
|
char* sbuf = new char[max];
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
-- Bruce Guenter <bruce@untroubled.org>
|
-- Bruce Guenter <bruce@untroubled.org>
|
||||||
Translation to simpler C++ Code
|
Translation to simpler C++ Code
|
||||||
-- Volker Grabsch <vog@notjusthosting.com>
|
-- Volker Grabsch <vog@notjusthosting.com>
|
||||||
|
Fixing bugs and improving style
|
||||||
|
-- Eugene Hopkinson <slowriot at voxelstorm dot com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SHA1_HPP
|
#ifndef SHA1_HPP
|
||||||
|
@ -46,8 +48,8 @@ private:
|
||||||
void reset();
|
void reset();
|
||||||
void transform(uint32 block[BLOCK_BYTES]);
|
void transform(uint32 block[BLOCK_BYTES]);
|
||||||
|
|
||||||
static void buffer_to_block(const std::string &buffer, uint32 block[BLOCK_BYTES]);
|
static void read(std::istream &is, std::string &s, size_t max);
|
||||||
static void read(std::istream &is, std::string &s, int max);
|
static void buffer_to_block(const std::string &buffer, uint32 block[BLOCK_INTS]);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string sha1(const std::string &string);
|
std::string sha1(const std::string &string);
|
||||||
|
|
Loading…
Reference in New Issue