From 97693d3833cec28dabd92d5730f3d0f68b541604 Mon Sep 17 00:00:00 2001 From: Marcel Poul Date: Sat, 10 Nov 2012 15:14:01 +0000 Subject: [PATCH] SIGSEGV happened if htproxyput was run by non-root user, checked fopen and fdopen return values now! --- org.gridsite.core/src/htproxyput.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/org.gridsite.core/src/htproxyput.c b/org.gridsite.core/src/htproxyput.c index 031a502..64a9bdb 100644 --- a/org.gridsite.core/src/htproxyput.c +++ b/org.gridsite.core/src/htproxyput.c @@ -265,12 +265,25 @@ int main(int argc, char *argv[]) fd = mkstemp(keycert); ofp = fdopen(fd, "w"); + if (!ofp) + { + printf(stderr, "Cannot open tmp file for the key\n"); + return 1; + } ifp = fopen(key, "r"); + { + printf(stderr, "Cannot open the file with the key\n"); + return 1; + } while ((c = fgetc(ifp)) != EOF) fputc(c, ofp); fclose(ifp); ifp = fopen(cert, "r"); + { + printf(stderr, "Cannot open the file with the cert\n"); + return 1; + } while ((c = fgetc(ifp)) != EOF) fputc(c, ofp); fclose(ifp); -- 1.8.2.3