OSSP CVS Repository

ossp - Difference in ossp-pkg/rc/rc_sect.c versions 1.9 and 1.10
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/rc/rc_sect.c 1.9 -> 1.10

--- rc_sect.c    2003/05/21 12:49:21     1.9
+++ rc_sect.c    2003/05/21 15:16:41     1.10
@@ -226,8 +226,11 @@
 ************************************************/
 rc_return_t sectionDump(rc_section_t *pSec)
 {
+    const char *szLogin = NULL;
+
     if (pSec) {
-        fprintf(stdout, "#su %s\n", sectionGetlogin(pSec));
+        if ((szLogin = sectionGetlogin(pSec)) != NULL)
+            fprintf(stdout, "#su %s\n", szLogin);
         fprintf(stdout, "%s", sectionGetdata(pSec));
         return(RC_THROW(RC_OK));
     }
@@ -242,9 +245,15 @@
 rc_return_t sectionWrite(rc_section_t *pSec, const char *szPath)
 {
     int nFdtmp = open(szPath, O_WRONLY | O_CREAT, 0600);
-    FILE *pStream = fdopen(nFdtmp, "w");
+    FILE *pStream = NULL;
+
+    /* Initial sanity checks */
+    if (!pSec || nFdtmp < 0)
+        return(RC_THROW(RC_ERR_USE));
+    else
+        pStream = fdopen(nFdtmp, "w");
 
-    if (pSec && pStream) {
+    if (pStream) {
         fprintf(pStream, "#su %s\n", sectionGetlogin(pSec));
         fprintf(pStream, "%s", sectionGetdata(pSec));
         fclose(pStream);

CVSTrac 2.0.1