diff options
| author | Jason Rumney | 2003-08-27 22:57:54 +0000 |
|---|---|---|
| committer | Jason Rumney | 2003-08-27 22:57:54 +0000 |
| commit | cb72110db2d80e522c199bde20d5c0857c0620fd (patch) | |
| tree | 7bff5405848f05cddb6038e828ca3b2c66323319 /src | |
| parent | d3703de36c308da1dea95bbd10505432b4e7950b (diff) | |
| download | emacs-cb72110db2d80e522c199bde20d5c0857c0620fd.tar.gz emacs-cb72110db2d80e522c199bde20d5c0857c0620fd.zip | |
(sys_pipe): Protect against file descriptor overflow.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32.c | 19 |
1 files changed, 15 insertions, 4 deletions
| @@ -3450,11 +3450,22 @@ sys_pipe (int * phandles) | |||
| 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 | if (phandles[0] >= MAXDESC || phandles[1] >= MAXDESC) | ||
| 3456 | { | ||
| 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; | ||
| 3455 | 3465 | ||
| 3456 | flags = FILE_PIPE | FILE_WRITE | FILE_BINARY; | 3466 | flags = FILE_PIPE | FILE_WRITE | FILE_BINARY; |
| 3457 | fd_info[phandles[1]].flags = flags; | 3467 | fd_info[phandles[1]].flags = flags; |
| 3468 | } | ||
| 3458 | } | 3469 | } |
| 3459 | 3470 | ||
| 3460 | return rc; | 3471 | return rc; |