Git Product home page Git Product logo

Comments (6)

defuse avatar defuse commented on June 3, 2024

A patch would be great, thanks!

from crackstation-hashdb.

erplefoo avatar erplefoo commented on June 3, 2024

Casting, format fixes, memsets & exits (the two size_t's in
freadIndexEntryAt will likely never get printed, but this made the
unused-return-value warning shut up :-)

diff --git a/checksort.c b/checksort.c
index 8e1acd1..d50cf58 100644
--- a/checksort.c
+++ b/checksort.c
@@ -12,6 +12,8 @@
// along with this program. If not, see http://www.gnu.org/licenses/.

#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <inttypes.h>

@@ -27,9 +29,19 @@ struct IndexEntry {

void freadIndexEntryAt(FILE* file, int64_t index, struct IndexEntry* out)
{

  • size_t fr1, fr2;
  • fr1 = 0;
  • fr2 = 0;
    fseek(file, index * INDEX_ENTRY_WIDTH, SEEK_SET);
  • fread(out->hash, sizeof(unsigned char), INDEX_HASH_WIDTH, file);
  • fread(out->position, sizeof(unsigned char), INDEX_POSITION_WIDTH, file);
  • fr1 = fread(out->hash, sizeof(unsigned char), INDEX_HASH_WIDTH, file);
  • fr2 = fread(out->position, sizeof(unsigned char), INDEX_POSITION_WIDTH, fil
  • if (fr1 != INDEX_HASH_WIDTH) {
  •    fprintf(stderr,"hash width != %d\n",INDEX_HASH_WIDTH);
    
  •    exit(1);
    
  • } else if (fr2 != INDEX_POSITION_WIDTH) {
  •    fprintf(stderr,"position width != %d\n",INDEX_POSITION_WIDTH);
    
  •    exit(1);
    
  • }
    }

/*
@@ -43,12 +55,12 @@ int hashcmp(const unsigned char hashA[INDEX_HASH_WIDTH], con
int i = 0;
for(i = 0; i < INDEX_HASH_WIDTH; i++)
{

  •    if(hashA[i] > hashB[i])
    
  •    if(hashA[i] > hashB[i]) {
         return 1;
    
  •    else if(hashA[i] < hashB[i])
    
  •    } else if(hashA[i] < hashB[i]) {
         return -1;
    
  •    }
    

    }

    return 0;
    }

@@ -56,8 +68,10 @@ int hashcmp(const unsigned char hashA[INDEX_HASH_WIDTH], cons
int main(int argc, char **argv)
{
struct IndexEntry current, max;

  • FILE* file = fopen(argv[1], "r+b");
  • FILE* file = fopen(argv[1], "rb");
  • memset(&current,0,sizeof(current));
  • memset(&max,0,sizeof(max));
    if(file == NULL)
    {
    printf("File does not exist.\n");
    @@ -66,12 +80,12 @@ int main(int argc, char **argv)

fseek(file, 0L, SEEK_END);
int64_t size = ftell(file);

  • if(size % INDEX_ENTRY_WIDTH != 0)
  • if(size % (int64_t)INDEX_ENTRY_WIDTH != 0)
    {
    printf("Invalid index file!\n");
    return 1;
    }
  • int64_t numEntries = size / INDEX_ENTRY_WIDTH;
  • int64_t numEntries = size / (int64_t)INDEX_ENTRY_WIDTH;

int64_t i;

@@ -81,14 +95,15 @@ int main(int argc, char **argv)
if(hashcmp(current.hash, max.hash) < 0) // Current is less than max
{
printf("NOT SORTED!!!!\n");

  •        return 2;
    
  •        exit(1);
     }
     max = current;
     if(i % 10000000 == 0)
     {
    
  •        printf("%d...\n", i);
    
  •        printf("%ld...\n", i);
     }
    

    }

    printf("ALL SORTED!\n");

  • exit(0);
    }

On Sun, Sep 7, 2014 at 9:32 AM, Taylor Hornby [email protected] wrote:

A patch would be great, thanks!


Reply to this email directly or view it on GitHub.

Sean

from crackstation-hashdb.

erplefoo avatar erplefoo commented on June 3, 2024

This is quite literally the first time I've sent a patch in to
something on github, so let me know if there was some handy command I
should've used instead of pasting it into email plz :)

On Mon, Sep 8, 2014 at 9:14 AM, Sean Davis [email protected] wrote:

Casting, format fixes, memsets & exits (the two size_t's in
freadIndexEntryAt will likely never get printed, but this made the
unused-return-value warning shut up :-)

diff --git a/checksort.c b/checksort.c
index 8e1acd1..d50cf58 100644
--- a/checksort.c
+++ b/checksort.c
@@ -12,6 +12,8 @@
// along with this program. If not, see http://www.gnu.org/licenses/.

#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <inttypes.h>

@@ -27,9 +29,19 @@ struct IndexEntry {

void freadIndexEntryAt(FILE* file, int64_t index, struct IndexEntry* out)
{

  • size_t fr1, fr2;
  • fr1 = 0;
  • fr2 = 0;
    fseek(file, index * INDEX_ENTRY_WIDTH, SEEK_SET);
  • fread(out->hash, sizeof(unsigned char), INDEX_HASH_WIDTH, file);
  • fread(out->position, sizeof(unsigned char), INDEX_POSITION_WIDTH, file);
  • fr1 = fread(out->hash, sizeof(unsigned char), INDEX_HASH_WIDTH, file);
  • fr2 = fread(out->position, sizeof(unsigned char), INDEX_POSITION_WIDTH, fil
  • if (fr1 != INDEX_HASH_WIDTH) {
  •    fprintf(stderr,"hash width != %d\n",INDEX_HASH_WIDTH);
    
  •    exit(1);
    
  • } else if (fr2 != INDEX_POSITION_WIDTH) {
  •    fprintf(stderr,"position width != %d\n",INDEX_POSITION_WIDTH);
    
  •    exit(1);
    
  • }
    }

/*
@@ -43,12 +55,12 @@ int hashcmp(const unsigned char hashA[INDEX_HASH_WIDTH], con
int i = 0;
for(i = 0; i < INDEX_HASH_WIDTH; i++)
{

  •    if(hashA[i] > hashB[i])
    
  •    if(hashA[i] > hashB[i]) {
         return 1;
    
  •    else if(hashA[i] < hashB[i])
    
  •    } else if(hashA[i] < hashB[i]) {
         return -1;
    
  •    }
    

    }

    return 0;
    }

@@ -56,8 +68,10 @@ int hashcmp(const unsigned char hashA[INDEX_HASH_WIDTH], cons
int main(int argc, char **argv)
{
struct IndexEntry current, max;

  • FILE* file = fopen(argv[1], "r+b");
  • FILE* file = fopen(argv[1], "rb");
  • memset(&current,0,sizeof(current));
  • memset(&max,0,sizeof(max));
    if(file == NULL)
    {
    printf("File does not exist.\n");
    @@ -66,12 +80,12 @@ int main(int argc, char **argv)

fseek(file, 0L, SEEK_END);
int64_t size = ftell(file);

  • if(size % INDEX_ENTRY_WIDTH != 0)
  • if(size % (int64_t)INDEX_ENTRY_WIDTH != 0)
    {
    printf("Invalid index file!\n");
    return 1;
    }
  • int64_t numEntries = size / INDEX_ENTRY_WIDTH;
  • int64_t numEntries = size / (int64_t)INDEX_ENTRY_WIDTH;

int64_t i;

@@ -81,14 +95,15 @@ int main(int argc, char **argv)
if(hashcmp(current.hash, max.hash) < 0) // Current is less than max
{
printf("NOT SORTED!!!!\n");

  •        return 2;
    
  •        exit(1);
     }
     max = current;
     if(i % 10000000 == 0)
     {
    
  •        printf("%d...\n", i);
    
  •        printf("%ld...\n", i);
     }
    

    }

    printf("ALL SORTED!\n");

  • exit(0);
    }

On Sun, Sep 7, 2014 at 9:32 AM, Taylor Hornby [email protected] wrote:

A patch would be great, thanks!


Reply to this email directly or view it on GitHub.

Sean

Sean

from crackstation-hashdb.

defuse avatar defuse commented on June 3, 2024

@erplefoo Oops, sorry I forgot about this. The usual way to submit a patch on GitHub is to fork the project and submit a pull request. However, pasting it into email is just as good. When I get some time (probably not for a long time), I'll review and apply the patch, thanks!

from crackstation-hashdb.

erplefoo avatar erplefoo commented on June 3, 2024

I figured I forgot something. No rush :)

On Sun, Mar 1, 2015 at 2:41 AM, Taylor Hornby [email protected]
wrote:

@erplefoo https://github.com/erplefoo Oops, sorry I forgot about this.
The usual way to submit a patch on GitHub is to fork the project and submit
a pull request. However, pasting it into email is just as good. When I get
some time (probably not for a long time), I'll review and apply the patch,
thanks!


Reply to this email directly or view it on GitHub
#1 (comment)
.

Sean

from crackstation-hashdb.

defuse avatar defuse commented on June 3, 2024

Applied the patch, great work!

from crackstation-hashdb.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.