title: Reading all file contents into string - Can I have problems passing value of off_t to malloc() (where expect size_t)?
body: <p>Can I have problems passing value of <code>off_t</code> to <code>malloc()</code> (where expect <code>size_t</code>)?</p>
  
  <p>I'm reading a file and storing its contents into memory. The file size is obtained by the <code>st_size</code> member from <code>struct stat</code> after passed to <code>stat()</code> function and then passed to <code>malloc()</code> where I will do a call to <code>fread()</code> passing the memory returned my <code>malloc()</code> as <code>buf</code> and file size as <code>nmemb</code>.</p>
  
  <p>But the question is: if the file size is really a big number that can't be held by a <code>size_t</code> what's the behavior of <code>malloc()</code> function on 32-bit/64-bit machine: integer overflow and a broken buf (not number of requested bytes was really returned) or <code>NULL</code>?</p>
  
  <p>I know that it may really never happens, so bit probably someone use this application into e.g, supercomputer and request a biggest file to my parser... but I really like to understand the maximum possible about the things, even behavior that can never happen. </p>