Commit bb240f05 authored by Mathieu Valois's avatar Mathieu Valois
Browse files

fix overflow for line numbers

parent 3f4253b1
Loading
Loading
Loading
Loading
+8 −8
Changes for Statsgen/include/statsgen.h: 8 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ struct minMax {
 * @brief All needed variables for the security rules
 */
struct SecurityRules {
	double nbSecurePassword;
	uint64_t nbSecurePassword;
	int minLength;
	int minSpecial;
	int minDigit;
@@ -82,12 +82,12 @@ struct SecurityRules {
struct thread_data {
	int thread_id;
	std::string filename;
	int lineBegin;
	int lineEnd;
	uint64_t lineBegin;
	uint64_t lineEnd;
	int queue_full = 0;

	double total_counter = 0;
	double total_filter = 0;
	uint64_t total_counter = 0;
	uint64_t total_filter = 0;

	std::unordered_map<int, uint64_t> length;
	std::unordered_map<std::wstring, uint64_t> simplemasks;
@@ -228,15 +228,15 @@ private:

	// Counters

	double total_counter = 0;		// number of analysed passwords
	double total_filter = 0;		// number of analysed passwords after a filter
	uint64_t total_counter = 0;		// number of analysed passwords
	uint64_t total_filter = 0;		// number of analysed passwords after a filter

	minMax minMaxValue;				// save all genral data from passwords 


	// Security policy

	double nbSecurePassword = 0;	// all passwords that respect the security rules
	uint64_t nbSecurePassword = 0;	// all passwords that respect the security rules
	int minLength = 8;
	int minSpecial = 0;
	int minDigit = 1;
+4 −4
Changes for Statsgen/include/utils.h: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ multimap<uint64_t, A> flip_map(const std::unordered_map<A, uint64_t> & src) {
 * @param hiderare: flag to hide statistics under 1%
 */
template<typename Type>
void readResult(double res, Type carac, int & count, const double & total_counter, const int & hiderare) {
void readResult(uint64_t res, Type carac, int & count, const uint64_t & total_counter, const int & hiderare) {
	float percentage;
	percentage = (float) (100*res) / total_counter;

@@ -82,7 +82,7 @@ void readResult(double res, Type carac, int & count, const double & total_counte
 * @param count: number of shown results
 */
template<typename Type>
void showMap(const unordered_map<Type, uint64_t> & stats, const int & top, const double & total_counter, const int & hiderare, int & count) {
void showMap(const unordered_map<Type, uint64_t> & stats, const int & top, const uint64_t & total_counter, const int & hiderare, int & count) {
	count = 0;
	multimap<uint64_t, Type> reverse = flip_map<Type>(stats);
	
@@ -107,10 +107,10 @@ void showMap(const unordered_map<Type, uint64_t> & stats, const int & top, const
 * @param filename: name of the file
 * @return number of line
 */
int nbline_file(const string & filename) {
uint64_t nbline_file(const string & filename) {
	wifstream readfile(filename);
	wstring line;
	int nb = 0;
	uint64_t nb = 0;

	while(readfile.good()) {
		getline(readfile, line);
+5 −5
Changes for Statsgen/src/statsgen.cpp: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ void Statsgen::setSecurityRules() {


int Statsgen::generate_stats() {
	int nbline = 0;
	uint64_t nbline = 0;
	if (!is_stdin){
		nbline = nbline_file(filename);
		if (!nbline){ // error reading the file
@@ -480,7 +480,7 @@ void * generate_stats_thread_queue(void * threadarg) {
	my_data = (struct thread_data *) threadarg;

	wstring line;
	int nbline = 0;
	uint64_t nbline = 0;
	while(1) {
		// there are passwords in stdin but they have not been pushed to the queue yet
		if (my_data->password_queue.empty() && !my_data->queue_full){
@@ -525,7 +525,7 @@ void * generate_stats_thread(void * threadarg) {

	wifstream readfile(my_data->filename);
	wstring line;
	int nbline = 0;
	uint64_t nbline = 0;

	while(readfile.good()) {
		++nbline;
@@ -545,7 +545,7 @@ void * generate_stats_thread(void * threadarg) {
		Container c;

		if (my_data->withcount) {
			uint i = 0;
			uint64_t i = 0;
			bool number=false;
			for(i=0; i < line.length(); i++) {
				if(iswdigit(line.at(i))) {
@@ -556,7 +556,7 @@ void * generate_stats_thread(void * threadarg) {
				}
			}
			wstring password = line.substr(i+1,line.length());
			int nbPasswords = stoi(line.substr(0,i));
			uint64_t nbPasswords = stoi(line.substr(0,i));
			
			my_data->total_counter += nbPasswords;