Note that there are some explanatory texts on larger screens.

plurals
  1. POFread on Lion does not read when length > 2G
    primarykey
    data
    text
    <p>Since Macosx Lion fread does not read file with length > 2G (int size, 2'147'483'648 bytes). It worked for years with macosx snow leopard.</p> <p>I wrote a program to test it :</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; int main(int argc, char *argv[]) { FILE *fin = NULL, *fout = NULL; char *ptr = NULL; size_t len; fpos_t flen; if (!(fin = fopen(argv[1], "rb"))) { printf("The input file: %s could not be opened\n", argv[1]); return -1; } if ((fout = fopen(argv[2], "rb"))) { printf("The output file %s already exist\n", argv[2]); fclose(fin); return -1; } if (!(fout = fopen(argv[2],"wb"))) { printf("Cannot write on output file %s\n", argv[2]); fclose(fin); return -1; } fseek(fin, 0, SEEK_END); fgetpos(fin, &amp;flen); len = flen; printf("Input file length : %zd\n", len); fseek(fin, 0, SEEK_SET); if (!(ptr = malloc(len))) { printf("Canot allocate %zd bytes\n", len); fclose(fin); fclose(fout); return -1; } if (fread(ptr, sizeof(char), len, fin) != len) { printf("Cannot read file\n"); fclose(fin); fclose(fout); free(ptr); return -1; } fclose(fin); if (fwrite(ptr, sizeof(char), len, fout) != len) { printf("Cannot write file\n"); fclose(fout); free(ptr); return -1; } free(ptr); fclose(fout); return 1; } </code></pre> <p>just run :</p> <ul> <li>./pgm inputfile outputfile</li> <li>openssl sha inputfile</li> <li>openssl sha outputfile</li> </ul> <p>There is no error. The length of the 2 files are the same. The two fingerprints are not the same. (The pointer is well allocated and write in the outputfile) Its only with fread, not fwrite.</p> <p>i don't understand the problem.</p> <p>I just see this program (i don't know if apple use this one on Lion) and r variable is defined as int. <a href="http://www.opensource.apple.com/source/Libc/Libc-186/stdio.subproj/fread.c" rel="nofollow">http://www.opensource.apple.com/source/Libc/Libc-186/stdio.subproj/fread.c</a></p> <p>Thanks for answers</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload