The availability of socketbits.h?

Xu Qiang Qiang.Xu at fujixerox.com
Tue May 17 21:55:43 PDT 2005


Dan Nelson wrote:
> The rest of the code in command.c makes use of the command_count value
> and assumes that all the array elements are fully populated.  The
> qsort routime tried to compare a NULL comm_name value and seg
> faulted.  His fix would have worked if the rest of the program used
> the same code loop as the one at command.c:1149, but it doesn't.

Yeah, you hit the point again! 

Just found the variable noofcomms (= COUNTOF(command_list)) is used in the function qsort() 
---------------------------------------------------------------------
qsort(&(command_list),noofcomms,sizeof command_list[0],&command_cmp);
---------------------------------------------------------------------

No wonder trailing NULL element at the end of the array command_list[] is used in qsort(), and the segmentation fault.

Since the number of actual non-NULL elements in the array is one less than the array's size, I changed the calculation of noofcomms as: 
---------------------------------------------------------------------
noofcomms = COUNTOF(command_list) - 1;
---------------------------------------------------------------------

Now the program can work properly. :)

> The author may not have tested it on many systems, and since the
> source is so old (relatively speaking), standards have changed.  It's
> no longer acceptable to provide your own prototypes for system
> functions, for example (which was the cause of your first few compile
> errors). 

I am very lucky to have you and Giorgos around to help me in compiling this software. Thank you two so much for your help and patience!

with my best wishes,
Xu Qiang




More information about the freebsd-questions mailing list