]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/util/volinfo.c
volinfo: test chdir return value
[netatalk.git] / libatalk / util / volinfo.c
index 2b0496044da9205ad7f4e664984443c816245c4f..646438b3cb770048aef567c9bc64d2147f55a7ed 100644 (file)
@@ -152,13 +152,13 @@ static char * make_path_absolute(char *path, size_t bufsize)
         *p = '\0';
     }
 
-    getcwd(savecwd, sizeof(savecwd));
-    if ((chdir(abspath)) < 0)  
+    if (!getcwd(savecwd, sizeof(savecwd)) || chdir(abspath) < 0)       
         return NULL;
 
-    getcwd(abspath, sizeof(abspath));
-    chdir (savecwd);
-
+    if (!getcwd(abspath, sizeof(abspath)) || chdir (savecwd) < 0)
+        return NULL;
+        
+    
     if (strlen(abspath) > bufsize)
         return NULL;
 
@@ -251,25 +251,25 @@ static int parseline ( char *buf, struct volinfo *vol)
     switch (option) {
       case MAC_CHARSET:
         if ((vol->v_maccodepage = strdup(value)) == NULL) {
-           fprintf (stderr, "strdup: %m");
+           fprintf (stderr, "strdup: %s", strerror(errno));
             return -1;
         }
         break;
       case VOL_CHARSET:
         if ((vol->v_volcodepage = strdup(value)) == NULL) {
-           fprintf (stderr, "strdup: %m");
+           fprintf (stderr, "strdup: %s", strerror(errno));
             return -1;
         }
         break;
       case CNIDBACKEND:
         if ((vol->v_cnidscheme = strdup(value)) == NULL) {
-           fprintf (stderr, "strdup: %m");
+           fprintf (stderr, "strdup: %s", strerror(errno));
             return -1;
         }
         break;
       case CNIDDBDHOST:
         if ((vol->v_dbd_host = strdup(value)) == NULL) {
-           fprintf (stderr, "strdup: %m");
+           fprintf (stderr, "strdup: %s", strerror(errno));
             return -1;
         }
         break;
@@ -278,7 +278,7 @@ static int parseline ( char *buf, struct volinfo *vol)
         break;
       case CNID_DBPATH:
         if ((vol->v_dbpath = strdup(value)) == NULL) {
-           fprintf (stderr, "strdup: %m");
+           fprintf (stderr, "strdup: %s", strerror(errno));
             return -1;
         }
         break;
@@ -341,7 +341,7 @@ int loadvolinfo (char *path, struct volinfo *vol)
         return -1;
 
     if ((vol->v_path = strdup(volinfofile)) == NULL ) {
-       fprintf (stderr, "strdup: %m");
+       fprintf (stderr, "strdup: %s", strerror(errno));
         return (-1);
     }
     strlcat(volinfofile, ".AppleDesktop/", sizeof(volinfofile));
@@ -349,7 +349,7 @@ int loadvolinfo (char *path, struct volinfo *vol)
 
     /* open the file read only */
     if ( NULL == (fp = fopen( volinfofile, "r")) )  {
-       fprintf (stderr, "error opening volinfo (%s): %m", volinfofile);
+       fprintf (stderr, "error opening volinfo (%s): %s", volinfofile, strerror(errno));
         return (-1);
     }
     fd = fileno(fp);