fs: display cell not available on ESRCH
[openafs.git] / src / venus / fs.c
index 5f7e968..4329434 100644 (file)
@@ -577,7 +577,7 @@ EmptyAcl(char *astr)
     tp->nplus = tp->nminus = 0;
     tp->pluslist = tp->minuslist = 0;
     tp->dfs = 0;
-    sscanf(astr, "%d dfs:%d %s", &junk, &tp->dfs, tp->cell);
+    sscanf(astr, "%d dfs:%d %1024s", &junk, &tp->dfs, tp->cell);
     return tp;
 }
 
@@ -592,7 +592,7 @@ ParseAcl(char *astr)
     ta = malloc(sizeof(struct Acl));
     assert(ta);
     ta->dfs = 0;
-    sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
+    sscanf(astr, "%d dfs:%d %1024s", &ta->nplus, &ta->dfs, ta->cell);
     astr = SkipLine(astr);
     sscanf(astr, "%d", &ta->nminus);
     astr = SkipLine(astr);
@@ -603,7 +603,7 @@ ParseAcl(char *astr)
     last = 0;
     first = 0;
     for (i = 0; i < nplus; i++) {
-       sscanf(astr, "%100s %d", tname, &trights);
+       sscanf(astr, "%99s %d", tname, &trights);
        astr = SkipLine(astr);
        tl = malloc(sizeof(struct AclEntry));
        assert(tl);
@@ -621,7 +621,7 @@ ParseAcl(char *astr)
     last = 0;
     first = 0;
     for (i = 0; i < nminus; i++) {
-       sscanf(astr, "%100s %d", tname, &trights);
+       sscanf(astr, "%99s %d", tname, &trights);
        astr = SkipLine(astr);
        tl = malloc(sizeof(struct AclEntry));
        assert(tl);
@@ -1726,8 +1726,8 @@ static int
 GetLastComponent(const char *data, char **outdir, char **outbase,
                 int *thru_symlink)
 {
-    char orig_name[1024];      /*Original name, may be modified */
-    char true_name[1024];      /*``True'' dirname (e.g., symlink target) */
+    char orig_name[MAXPATHLEN];        /*Original name, may be modified */
+    char true_name[MAXPATHLEN];        /*``True'' dirname (e.g., symlink target) */
     char *lastSlash;
     struct stat statbuff;      /*Buffer for status info */
     int link_chars_read;       /*Num chars read in readlink() */
@@ -1758,8 +1758,8 @@ GetLastComponent(const char *data, char **outdir, char **outbase,
        if (thru_symlink)
             *thru_symlink = 1;
 
-       /* Read name of resolved file */
-       link_chars_read = readlink(orig_name, true_name, 1024);
+       /* Read name of resolved file (leave space for NULL!) */
+       link_chars_read = readlink(orig_name, true_name, MAXPATHLEN-1);
        if (link_chars_read <= 0) {
            fprintf(stderr,
                    "%s: Can't read target name for '%s' symbolic link!\n",
@@ -1931,8 +1931,13 @@ defect #3069
        blob.in_size = 0;
        blob.out_size = AFS_PIOCTL_MAXSIZE;
        blob.out = space;
-       pioctl(Parent(as->parms[0].items->data), VIOC_FILE_CELL_NAME,
-              &blob, 1);
+       code = pioctl(Parent(as->parms[0].items->data), VIOC_FILE_CELL_NAME,
+                     &blob, 1);
+       if (code) {
+          fprintf(stderr,
+                  "%s: couldn't get cell name for file's parent\n", pn);
+          return 1;
+       }
     }
 
     dir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
@@ -4005,6 +4010,9 @@ Die(int errnum, char *filename)
                    "%s: You do not have the required rights to do this operation\n",
                    pn);
        break;
+    case ESRCH: /* hack: pioctls stole ESRCH for cell name not available errors. */
+       fprintf(stderr, "%s: Cell name not recognized.\n", pn);
+       break;
     default:
        if (filename)
            fprintf(stderr, "%s:'%s'", pn, filename);