From 4d0ee443d1f45d0b761e3c850a77e3d7849981b9 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 1 Feb 2013 21:55:29 +0100 Subject: [PATCH] Fix crash in nfc-relay-picc -i/-t if fd3 or fd4 is missing --- utils/nfc-relay-picc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/utils/nfc-relay-picc.c b/utils/nfc-relay-picc.c index 5daf23e..bc7ab00 100644 --- a/utils/nfc-relay-picc.c +++ b/utils/nfc-relay-picc.c @@ -207,8 +207,14 @@ main(int argc, char *argv[]) ERR("No device found"); return EXIT_FAILURE; } - fd3 = fdopen(3, "r"); - fd4 = fdopen(4, "w"); + if ((fd3 = fdopen(3, "r")) == NULL) { + ERR("Could not open file descriptor 3"); + return EXIT_FAILURE; + } + if ((fd4 = fdopen(4, "r")) == NULL) { + ERR("Could not open file descriptor 4"); + return EXIT_FAILURE; + } } else { if (szFound < 2) { ERR("%zd device found but two opened devices are needed to relay NFC.", szFound);