[GH-ISSUE #599] nWordFileLines (and related line counting vars) should not be unsigned int/long. #269

Closed
opened 2026-10-14 02:59:12 +07:00 by bsakaguchi · 12 comments
Owner

Originally created by @rofl0r on GitHub (May 23, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/599

a file clearly can have more than 2^32 lines.
my preference would be to define those vars as uint64_t, but if there are performance implications on 32bit targets with 32bit off_t (maybe win32 or some embedded platforms), we could use an unsigned type with the sizeof(off_t) instead.

Originally created by @rofl0r on GitHub (May 23, 2014). Original GitHub issue: https://github.com/openwall/john/issues/599 a file clearly can have more than 2^32 lines. my preference would be to define those vars as uint64_t, but if there are performance implications on 32bit targets with 32bit off_t (maybe win32 or some embedded platforms), we could use an unsigned type with the sizeof(off_t) instead.
Author
Owner

@magnumripper commented on GitHub (May 23, 2014):

Agreed. IMHO they should definitely be size_t which would be sensible on both 32 and 64 bit archs.

<!-- gh-comment-id:44052840 --> @magnumripper commented on GitHub (May 23, 2014): Agreed. IMHO they should definitely be `size_t` which would be sensible on both 32 and 64 bit archs.
Author
Owner

@rofl0r commented on GitHub (May 23, 2014):

not really, size_t is always 32 bit on a 32bit arch, even if they have 64 bit off_t (i.e. everything supporting files > 2GB)

<!-- gh-comment-id:44053153 --> @rofl0r commented on GitHub (May 23, 2014): not really, size_t is always 32 bit on a 32bit arch, even if they have 64 bit off_t (i.e. everything supporting files > 2GB)
Author
Owner

@magnumripper commented on GitHub (May 23, 2014):

That doesn't mean it's sensible. I stick with my opinion about size_t.

<!-- gh-comment-id:44053407 --> @magnumripper commented on GitHub (May 23, 2014): That doesn't mean it's sensible. I stick with my opinion about size_t.
Author
Owner

@magnumripper commented on GitHub (May 24, 2014):

To reach 4 billion lines without excessive dupes, a file would need to be minimum 21 GB or so. I can see no reasonable use of such a file. What would it contain that rules or a generator mode could not do a whole lot better? Even 'wikipedia wordlist' is less than one gigabyte.

<!-- gh-comment-id:44081920 --> @magnumripper commented on GitHub (May 24, 2014): To reach 4 billion lines without excessive dupes, a file would need to be _minimum_ 21 GB or so. I can see no reasonable use of such a file. What would it contain that rules or a generator mode could not do a whole lot better? Even 'wikipedia wordlist' is less than one gigabyte.
Author
Owner

@rofl0r commented on GitHub (May 24, 2014):

i have a file generated from this c code - it is exactly 4 billion lines and 36GB

#include <stdio.h>
#include <stdint.h>

int main() {
    uint64_t i;
    for(i = 0; i <= 0xffffffff; i++) {
        printf("%.8X\n", (unsigned)i);
    }
}

(ETA code overflows)

<!-- gh-comment-id:44084260 --> @rofl0r commented on GitHub (May 24, 2014): i have a file generated from this c code - it is exactly 4 billion lines and 36GB ``` c #include <stdio.h> #include <stdint.h> int main() { uint64_t i; for(i = 0; i <= 0xffffffff; i++) { printf("%.8X\n", (unsigned)i); } } ``` (ETA code overflows)
Author
Owner

@magnumripper commented on GitHub (May 24, 2014):

That is the opposite of reasonable use. Save yourself 36 GB of disk space and use --mask=0x[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F].

<!-- gh-comment-id:44100556 --> @magnumripper commented on GitHub (May 24, 2014): That is the _opposite_ of reasonable use. Save yourself 36 GB of disk space and use `--mask=0x[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]`.
Author
Owner

@rofl0r commented on GitHub (May 24, 2014):

there will always be situations when its not clear how to create a certain rule, and its much easier to hack up a program to generate a wordlist. having a temporary wordlist with a couple GB around doesnt hurt, and it can even be quickly consumed given a fast hashtype.
i don't think john developers should discourage users from finding creative usage scenarios, instead of fixing the program so it doesnt break.

<!-- gh-comment-id:44105237 --> @rofl0r commented on GitHub (May 24, 2014): there will always be situations when its not clear how to create a certain rule, and its much easier to hack up a program to generate a wordlist. having a temporary wordlist with a couple GB around doesnt hurt, and it can even be quickly consumed given a fast hashtype. i don't think john developers should discourage users from finding creative usage scenarios, instead of fixing the program so it doesnt break.
Author
Owner

@magnumripper commented on GitHub (May 25, 2014):

IMO if you hack up a program or a perl script to generate such a list (which is totally sensible), you'd use the --stdin or --pipe option unless you are completely out of your mind or a totally clueless script kiddie.

This is yet another moot discussion. Better than continuing this with ridiculous arguments, you could simply:

  1. Create a patch that implements what you want (including lifting the 2 GB restriction for 32-bit builds - this is something we do want and @jfoug mentioned it just days ago)
  2. Benchmark it.
  3. Say "hey magnum, I benchmarked this and I have established that 64-bit variables does not hurt performance of a 32-bit system"

I assure you that will work a whole lot better. If you can't or do not want to do it, just wait for us to do it at some point in time (might be tomorrow, might be next year). This issue is open.

<!-- gh-comment-id:44108179 --> @magnumripper commented on GitHub (May 25, 2014): IMO if you hack up a program or a perl script to generate such a list (which is totally sensible), you'd use the `--stdin` or `--pipe` option unless you are completely out of your mind or a totally clueless script kiddie. This is yet another moot discussion. Better than continuing this with ridiculous arguments, you could simply: 1. Create a patch that implements what you want (including lifting the 2 GB restriction for 32-bit builds - this is something we _do_ want and @jfoug mentioned it just days ago) 2. Benchmark it. 3. Say "hey magnum, I benchmarked this and I have established that 64-bit variables does not hurt performance of a 32-bit system" I assure you that will work a **whole lot** better. If you can't or do not want to do it, just wait for us to do it at some point in time (might be tomorrow, might be next year). This issue is open.
Author
Owner

@rofl0r commented on GitHub (May 25, 2014):

if you really care about 32bit performance (i mean noone but a person "out of its mind or a totally clueless script kiddie" would use a 32bit platform for a serious cracking anyway) just use size_t aka unsigned long so we at least get 64bit on 64bit. i personally dont care an inch about i386 since my computer has more than 4GB RAM (and that's been nearly 10 years).
//edit: for x32 we should use long long tho...

<!-- gh-comment-id:44123204 --> @rofl0r commented on GitHub (May 25, 2014): if you really care about 32bit performance (i mean noone but a person "out of its mind or a totally clueless script kiddie" would use a 32bit platform for a serious cracking anyway) just use size_t aka unsigned long so we at least get 64bit on 64bit. i personally dont care an inch about i386 since my computer has more than 4GB RAM (and that's been nearly 10 years). //edit: for x32 we should use long long tho...
Author
Owner

@magnumripper commented on GitHub (May 25, 2014):

Right. The X32 issue is an interesting point. Many functions return size_t and ftell() returns long. Both are 32-bit on X32 (the latter is 32-bit on Win64 too but size_t must be 64-bit - I assume it's unsigned long long). I suppose that means X32 will have same limitations as a 32-bit build in this regard unless we do something about it.

<!-- gh-comment-id:44128332 --> @magnumripper commented on GitHub (May 25, 2014): Right. The X32 issue is an interesting point. Many functions return `size_t` and ftell() returns `long`. Both are 32-bit on X32 (the latter is 32-bit on Win64 too but `size_t` must be 64-bit - I assume it's `unsigned long long`). I suppose that means X32 will have same limitations as a 32-bit build in this regard unless we do something about it.
Author
Owner

@magnumripper commented on GitHub (May 25, 2014):

I looked into this. nWordFileLines et al are only used with memory buffering so this issue is moot. You wouldn't want to load a 36 GB file into a static memory buffer and index it with yet another 32 GB, would you?

Here's an actual problem though:

        /* this will both get us the file length, and tell us
           of 'invalid' files (i.e. too big in Win32 or other
           32 bit OS's.  A file between 2gb and 4gb returns
           a negative number. */
        fseek(word_file, 0, SEEK_END);
        file_len = ftell(word_file);
        fseek(word_file, 0, SEEK_SET);
        if (file_len < 0) {
            if (john_main_process)
                fprintf(stderr, "Error, dictionary file is too"
                        " large for john to read (probably a "
                        "32 bit OS issue)\n");
            error();
        }

Like I said, @jfoug wants to lift this restriction. I agree but I leave it to him: I don't care much about 32-bit.

<!-- gh-comment-id:44138855 --> @magnumripper commented on GitHub (May 25, 2014): I looked into this. nWordFileLines et al are only used with memory buffering so this issue is moot. You wouldn't want to load a 36 GB file into a static memory buffer and index it with yet another 32 GB, would you? Here's an actual problem though: ``` /* this will both get us the file length, and tell us of 'invalid' files (i.e. too big in Win32 or other 32 bit OS's. A file between 2gb and 4gb returns a negative number. */ fseek(word_file, 0, SEEK_END); file_len = ftell(word_file); fseek(word_file, 0, SEEK_SET); if (file_len < 0) { if (john_main_process) fprintf(stderr, "Error, dictionary file is too" " large for john to read (probably a " "32 bit OS issue)\n"); error(); } ``` Like I said, @jfoug wants to lift this restriction. I agree but I leave it to him: I don't care much about 32-bit.
Author
Owner

@magnumripper commented on GitHub (May 25, 2014):

Oh BTW you could argue that rec_line and other variables should be long long or size_t and I would agree. It's just that changing that would break session file compatibility with core. That's a no-no. So you'll have to convince Solar to fix core John first.

<!-- gh-comment-id:44138928 --> @magnumripper commented on GitHub (May 25, 2014): Oh BTW you could argue that rec_line and other variables should be `long long` or `size_t` and I would agree. It's just that changing that would break session file compatibility with core. That's a no-no. So you'll have to convince Solar to fix core John first.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#269
No description provided.