Regarding EFBIG error while opening a file using catopen() function

Kavita Gore kavitagore02@gmail.com
Mon Dec 12 05:10:20 GMT 2022


Hi all,

I'm getting errno 27[EFBIG] file too large while opening catalogue with
catopen() function in the cygwin-32bit version.



Trying to open a .cat file but catopen() returns a file too large [EFBIG]
error.



this is the code snippet I was working with:



#define FILENAME    TEMP.CAT



   buffer = catopen(FILENAME, 0);

        if (buffer != (nl_catd) - 1)

         {

            printf("File open successfully");

        }

        else

        {

            printf("errno: %d\n", errno);

        }





While debugging using gdb.I've found that st.st_size is 0 and As per my
understanding struct stat.st_size is declared as off_t, which is most
probably signed, and resolves to long (signed by default).

So if SIZE_T_MAX does not fit into 2^31-1 (it most probably does not) it
will appear as negative in the comparison.

I suspect like off_t is supposed to be signed, and size_t is supposed to be
unsigned, both according to POSIX.

That means, this comparison has definitely a signedness issue.

So that's why if condition getting success and returning errno 27(EFBIG).



Coding snippet where if condition getting succeed:

Msgcat.c:

=======

if (st.st_size > SIZE_T_MAX) {

        _close(fd);

        SAVEFAIL(name, lang, EFBIG);

        NLRETERR(EFBIG);

    }


I'd like to know the reason why I'm getting this error and How it can be
resolved as it is a blocker in my task.


Regards,

Kavita.


More information about the Cygwin mailing list