From 3a523b43d44fc4d126dce92706523de860ff577c Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 6 Feb 2025 15:35:49 +0100 Subject: [PATCH] gpgscm: Fix possible segv in the process functions. * tests/gpgscm/ffi.c (do_process_spawn_io): Fix use of FD_ISSET. -- This bug was detected on an i686 with gcc 4.1 and Linux 2.6.18 Fixes-commit: 1b0ce9918c321a5060fb7c59a234ab683187e8c1 --- tests/gpgscm/ffi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/gpgscm/ffi.c b/tests/gpgscm/ffi.c index 1179e01c0..21ec6a057 100644 --- a/tests/gpgscm/ffi.c +++ b/tests/gpgscm/ffi.c @@ -1055,7 +1055,7 @@ do_process_spawn_io (scheme *sc, pointer args) if (ret < 0) break; - if (FD_ISSET (out_fd, &read_fdset)) + if (out_fd >= 0 && FD_ISSET (out_fd, &read_fdset)) { bytes_read = read (out_fd, out_string + out_off, out_len - out_off); @@ -1079,7 +1079,7 @@ do_process_spawn_io (scheme *sc, pointer args) } } - if (FD_ISSET (err_fd, &read_fdset)) + if (err_fd >= 0 && FD_ISSET (err_fd, &read_fdset)) { bytes_read = read (err_fd, err_string + err_off, err_len - err_off);