/* NT client CellServDB has different file name than NT server or Unix */
if (_afsconf_IsClientConfigDirectory(adir->name)) {
if (!afssw_GetClientCellServDBDir(&p)) {
- asprintf(path, "%s/%s", p, AFSDIR_CELLSERVDB_FILE_NTCLIENT);
+ if (asprintf(path, "%s/%s", p, AFSDIR_CELLSERVDB_FILE_NTCLIENT) < 0)
+ *path = NULL;
free(p);
} else {
- asprintf(path, "%s/%s", adir->name, AFSDIR_CELLSERVDB_FILE_NTCLIENT);
+ if (asprintf(path, "%s/%s", adir->name,
+ AFSDIR_CELLSERVDB_FILE_NTCLIENT) < 0)
+ *path = NULL;
}
} else {
- asprintf(path, "%s/%s", adir->name, AFSDIR_CELLSERVDB_FILE);
+ if (asprintf(path, "%s/%s", adir->name, AFSDIR_CELLSERVDB_FILE) < 0)
+ *path = NULL;
}
return;
}
static void
_afsconf_CellServDBPath(struct afsconf_dir *adir, char **path)
{
- asprintf(path, "%s/%s", adir->name, AFSDIR_CELLSERVDB_FILE);
+ if (asprintf(path, "%s/%s", adir->name, AFSDIR_CELLSERVDB_FILE) < 0)
+ *path = NULL;
}
#endif /* AFS_NT40_ENV */
/* The "AFSCONF" environment (or contents of "/.AFSCONF") will be typically set to something like "/afs/<cell>/common/etc" where, by convention, the default files for "ThisCell" and "CellServDB" will reside; note that a major drawback is that a given afs client on that cell may NOT contain the same contents... */
char *home_dir;
afsconf_FILE *fp;
- size_t len;
+ size_t len = 0;
+ int r;
if (!(home_dir = getenv("HOME"))) {
/* Our last chance is the "/.AFSCONF" file */
if (fp == 0)
goto fail;
- fgets(afs_confdir, 128, fp);
- fclose(fp);
} else {
char *pathname = NULL;
- asprintf(&pathname, "%s/%s", home_dir, ".AFSCONF");
- if (pathname == NULL)
+ r = asprintf(&pathname, "%s/%s", home_dir, ".AFSCONF");
+ if (r < 0 || pathname == NULL)
goto fail;
fp = fopen(pathname, "r");
if (fp == 0)
goto fail;
}
- fgets(afs_confdir, 128, fp);
- fclose(fp);
}
- len = strlen(afs_confdir);
+ if (fgets(afs_confdir, 128, fp) != NULL)
+ len = strlen(afs_confdir);
+ fclose(fp);
if (len == 0)
goto fail;
int *numServers, int *ttl, char **arealCellName)
{
int code = 0;
+ int r;
int len;
unsigned char answer[4096];
unsigned char *p;
#endif
retryafsdb:
+ r = -1;
switch (pass) {
case 0:
dnstype = T_SRV;
- asprintf(&dotcellname, "_%s._%s.%s.", IANAname, protocol, cellName);
+ r = asprintf(&dotcellname, "_%s._%s.%s.", IANAname, protocol, cellName);
break;
case 1:
dnstype = T_AFSDB;
- asprintf(&dotcellname, "%s.", cellName);
+ r = asprintf(&dotcellname, "%s.", cellName);
break;
case 2:
dnstype = T_SRV;
- asprintf(&dotcellname, "_%s._%s.%s", IANAname, protocol, cellName);
+ r = asprintf(&dotcellname, "_%s._%s.%s", IANAname, protocol, cellName);
break;
case 3:
dnstype = T_AFSDB;
- asprintf(&dotcellname, "%s", cellName);
+ r = asprintf(&dotcellname, "%s", cellName);
break;
}
- if (dotcellname == NULL)
+ if (r < 0 || dotcellname == NULL)
goto findservererror;
LOCK_GLOBAL_MUTEX;
for (i=0 ; he->h_addr_list[i] && numServers < MAXHOSTSPERCELL; i++) {
/* check to see if this is a new address; if so insert it into the list */
int k, dup;
+ afs_uint32 addr;
+ memcpy(&addr, he->h_addr_list[i], sizeof(addr));
for (k=0, dup=0; !dup && k < numServers; k++) {
- afs_uint32 addr;
- memcpy(&addr, he->h_addr_list[i], sizeof(addr));
if (hostAddr[k].sin_addr.s_addr == addr) {
dup = 1;
}
*
* @return status
* @retval 0 success
- * @retval AFSCONF_UNKNOWN failed to get cellname
+ * @retval AFSCONF_NOCELLNAME cannot determine local cell name
*
* @internal
*/
if (adir->cellName) {
*pname = adir->cellName;
} else
- code = AFSCONF_UNKNOWN;
+ code = AFSCONF_NOCELLNAME;
}
return code;
}