From: Marcel Poul Date: Sat, 10 Nov 2012 15:14:01 +0000 (+0000) Subject: SIGSEGV happened if htproxyput was run by non-root user, checked fopen and fdopen... X-Git-Tag: gridsite-core_R_2_0_3~4 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=97693d3833cec28dabd92d5730f3d0f68b541604;p=jra1mw.git SIGSEGV happened if htproxyput was run by non-root user, checked fopen and fdopen return values now! --- 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);