Hi all,
A mental lapse during the use of recvfrom brought up a question about
argument error checking. Here is the offending snippet of code
if (recvfrom(s, reply, &len, 0, &dest, &dest_len) == -1) {
...
}
You will note that I supplied the address of the length of the reply
buffer rather than the length itself. Thanks to C's cavalier attitude
about pointers and integers, the pointer silently became a negative
int. The call did not fail but no data was received.
It seems to me that a negative buffer size is never acceptable and
hence recvfrom should have returned -1 and set errno to EINVAL to
alert me to my stupidity. My question: should the few lines of code
necessary to perform the check be inserted?
(In this case, the pointer could just as easily have become a positive
integer and hence not shown up as an error even with additional error
checking.)
Mark
--
Mark K. Gardner
RADIANT Team
Network Engineering, CIC-5
Los Alamos National Laboratory
P.O. Box 1663, M.S. D451
Los Alamos, NM 87545
Email: [EMAIL PROTECTED]
Phone: 1-505-665-4953
--
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]