Skip to content
Commit 2b79bc4f authored by Jeff Mahoney's avatar Jeff Mahoney Committed by Linus Torvalds
Browse files

dup2: Fix return value with oldfd == newfd and invalid fd



The return value of dup2 when oldfd == newfd and the fd isn't valid is
not getting properly sign extended.  We end up with 4294967287 instead
of -EBADF.

I've reproduced this on SLE11 (2.6.27.21), openSUSE Factory
(2.6.29-rc5), and Ubuntu 9.04 (2.6.28).

This patch uses a signed int for the error value so it is properly
extended.

Commit 6c5d0512 introduced this
regression.

Reported-by: default avatarJiri Dluhos <jdluhos@novell.com>
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fd18de50
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment