Re: AF_UNIX MSG_PEEK bug?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Rick Jones <rick.jones2@...>
Cc: <netdev@...>, David Miller <davem@...>, <linux-kernel@...>
Date: Tuesday, January 8, 2008 - 7:20 pm

On Tue, 8 Jan 2008, Rick Jones wrote:


That's entirely reasonable, and probably a worthwhile change to make.
But, as you say, it doesn't change whether or not this is a bug in
the MSG_PEEK code.

With a small bit of complication I certainly can do what you suggest.

The initial reasoning was that this made it easy to handle the case where
the caller of the library routine (my code which stumbled on this was
part of a small library I wrote as part of the application) did not supply
a sufficiently sized buffer for reception of the next message.  The "easy"
way to do this was a MSG_PEEK to validate the buffer size against the
message size, followed by a regular recv() if the buffer is large enough.
To do what you suggest (which effectively works around the bug) is certainly
possible, but also requires maintaining state between calls to the
"get message" routine, as I need to track whether or not the size has already
been read from the next message on the stream socket.

The change isn't terribly difficult, but wasn't the initial idea.

Plus it's always good to flush a bug out of hiding, right? ;)

Brent

-- 
Brent Casavant                          All music is folk music.  I ain't
bcasavan@sgi.com                        never heard a horse sing a song.
Silicon Graphics, Inc.                    -- Louis Armstrong
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
AF_UNIX MSG_PEEK bug?, Brent Casavant, (Tue Jan 8, 6:27 pm)
Re: AF_UNIX MSG_PEEK bug?, Tetsuo Handa, (Wed Jan 9, 7:04 am)
Re: AF_UNIX MSG_PEEK bug?, Brent Casavant, (Wed Jan 9, 2:01 pm)
Re: AF_UNIX MSG_PEEK bug?, Herbert Xu, (Wed Jan 9, 8:01 pm)
Re: AF_UNIX MSG_PEEK bug?, Brent Casavant, (Wed Jan 9, 10:50 pm)
Re: AF_UNIX MSG_PEEK bug?, Brent Casavant, (Thu Jan 10, 6:35 pm)
Re: AF_UNIX MSG_PEEK bug?, Alan Cox, (Thu Jan 10, 6:36 pm)
Re: AF_UNIX MSG_PEEK bug?, Brent Casavant, (Wed Jan 9, 9:19 pm)
Re: AF_UNIX MSG_PEEK bug?, Rick Jones, (Tue Jan 8, 6:40 pm)
Re: AF_UNIX MSG_PEEK bug?, Brent Casavant, (Tue Jan 8, 7:20 pm)
Re: AF_UNIX MSG_PEEK bug?, Tom Spink, (Tue Jan 8, 6:53 pm)
Re: AF_UNIX MSG_PEEK bug?, Brent Casavant, (Tue Jan 8, 7:18 pm)
Re: AF_UNIX MSG_PEEK bug?, Tom Spink, (Tue Jan 8, 7:39 pm)
Re: AF_UNIX MSG_PEEK bug?, Tom Spink, (Tue Jan 8, 7:46 pm)
Re: AF_UNIX MSG_PEEK bug?, Brent Casavant, (Tue Jan 8, 8:08 pm)