This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

FAXLIB examples: bug report

Hello,

I've found few bugs in FAXLIB examples code:

- multiple (faxsim.c, fiusim.c, fmsim.c) NULL pointer dereferences and assigning enum to string, general pattern:

char *str = NULL;
result = fmGetSizes (&fmNbufs, &bufs);
if (!(result == fm_NOERR))
{
*str = SIU_EXCEPTION_FM_SIZES_ERR; ///< NULL dererefence + assigning enum to string 1st byte
siuFatalError (SIU_FM_ID, str);
}

- extra arguments in printf() calls inside fiuDebugGetFRF11PacketType(), fiuDebugGetAAL2PacketType().

  • Tomeko,

    Are you referring to FAXLIB 2.1.0.1?

    "- extra arguments in printf() calls inside fiuDebugGetFRF11PacketType(), fiuDebugGetAAL2PacketType()."==========> Do you mean something like: sprintf (string, "idle", msgData);

    Those are just testing application code. Do you see any real issue when using the library? I will let our developer know, thanks for your suggestion to improve our code.

    Regards, Eric

  • lding said:

    Are you referring to FAXLIB 2.1.0.1?

    "- extra arguments in printf() calls inside fiuDebugGetFRF11PacketType(), fiuDebugGetAAL2PacketType()."==========> Do you mean something like: sprintf (string, "idle", msgData);

    Yes and yes.

    lding said:

    Those are just testing application code. Do you see any real issue when using the library?

    No, I'm just starting using it.

    lding said:

    I will let our developer know, thanks for your suggestion to improve our code.

    Thanks. I think these problems are insignificant, but since FAXLIB is mostly closed source and code review is limited I think it would be worth scanning with cppcheck - it points out these kinds of problems.

  • A little bit confusion for this: sprintf (string, "idle", msgData); what is the extra arguments and what is your suggested change? The syntax for sprintf looks OK: http://www.tutorialspoint.com/c_standard_library/c_function_sprintf.htm. Can you explain?

    Regards, Eric

  • Extra argument = argument not included in formatting string, msgData. It won't cause any damage, but it would produce warnings with gcc, clang and probably any static analyzer.

    Also, my comment about assigning enum to first byte of string was incorrect, I was confused with naming "str" and "string" for variables that should just hold numeric value. NULL pointer dereferencing is a separate error although and it's easy to spot with static analyzer - that's why I would advocate using e.g. cppcheck.