Mercurial > emacs
comparison src/w32.c @ 52353:373b8dc17c8b
(sys_pipe): Protect against file descriptor overflow.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Wed, 27 Aug 2003 22:57:54 +0000 |
parents | 23a1cea22d13 |
children | 695cf19ef79e |
comparison
equal
deleted
inserted
replaced
52352:f88c9c046632 | 52353:373b8dc17c8b |
---|---|
3448 if required. */ | 3448 if required. */ |
3449 rc = _pipe (phandles, 0, _O_NOINHERIT | _O_BINARY); | 3449 rc = _pipe (phandles, 0, _O_NOINHERIT | _O_BINARY); |
3450 | 3450 |
3451 if (rc == 0) | 3451 if (rc == 0) |
3452 { | 3452 { |
3453 flags = FILE_PIPE | FILE_READ | FILE_BINARY; | 3453 /* Protect against overflow, since Windows can open more handles than |
3454 fd_info[phandles[0]].flags = flags; | 3454 our fd_info array has room for. */ |
3455 | 3455 if (phandles[0] >= MAXDESC || phandles[1] >= MAXDESC) |
3456 flags = FILE_PIPE | FILE_WRITE | FILE_BINARY; | 3456 { |
3457 fd_info[phandles[1]].flags = flags; | 3457 _close (phandles[0]); |
3458 _close (phandles[1]); | |
3459 rc = -1; | |
3460 } | |
3461 else | |
3462 { | |
3463 flags = FILE_PIPE | FILE_READ | FILE_BINARY; | |
3464 fd_info[phandles[0]].flags = flags; | |
3465 | |
3466 flags = FILE_PIPE | FILE_WRITE | FILE_BINARY; | |
3467 fd_info[phandles[1]].flags = flags; | |
3468 } | |
3458 } | 3469 } |
3459 | 3470 |
3460 return rc; | 3471 return rc; |
3461 } | 3472 } |
3462 | 3473 |