[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: pong2 - PATH_MAX patch for review



On 06/20/2012 02:37 PM, Barry deFreese wrote:

Thanks but what are you doing there if you overrun the size of filename (not that they are handling
it now either but PATH_MAX is fairly large).


Well, it seems like this function does not return anything, so you can't use an error code. You could just exit(EXIT_FAILURE): after all, size isn't supposed to be larger than PATH_MAX (on systems that define it), so it's probably pretty bad if it is.

You could also write:

#ifdef PATH_MAX
size = PATH_MAX
#else
size = strlen(...)+1;
#endif
filename = malloc(size);
...


But duplicating the calls to sprintf() seems pretty bad.


Cyril.


Reply to: