SIGSEGV happened if htproxyput was run by non-root user, checked fopen and fdopen...
authorMarcel Poul <marcel.poul@cern.ch>
Sat, 10 Nov 2012 15:14:01 +0000 (15:14 +0000)
committerMarcel Poul <marcel.poul@cern.ch>
Sat, 10 Nov 2012 15:14:01 +0000 (15:14 +0000)
org.gridsite.core/src/htproxyput.c

index 031a502..64a9bdb 100644 (file)
@@ -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);