This code is written provided that sizeof( size_t ) is equal to sizeof( long ). But this assumption is valid only for 32-bit systems. So this code is depended on the system where it is used. Of course it is a bad code but it is not easy to write system-independent code where functions fread and ftell are used simultaneously. I can point another drawback in the statement
buffer = (char*) malloc (sizeof(char)*lSize);
Again if sizeof( size_t ) is less than long then there is a truncation of the expression sizeof(char)*lSize.
How would size_t be less than long? Isn't size_t used precisely because it
is guaranteed to be big enough to contain the size of the biggest object
the system can handle -- i.e., larger than long, by definition.