summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2004-02-27 19:17:37 +0000
committerBob Beck <beck@cvs.openbsd.org>2004-02-27 19:17:37 +0000
commit500d9ba660a2a88e0c74efa2cc571b6abc7efc12 (patch)
treef692a64cc436ff971bf0426074de42ff87d70774 /usr.sbin
parentbdb44c43bd8d90dd3e77ea187fdaed8d1934ad1c (diff)
fix bogus assert() usage in afsd, and avoid an assert when
ThisCell is specified as a nonexeistent cell. found by matthieu@, ok deraadt@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/afs/src/arlad/cred.c4
-rw-r--r--usr.sbin/afs/src/arlad/disco.c5
-rw-r--r--usr.sbin/afs/src/arlad/fcache.c56
-rw-r--r--usr.sbin/afs/src/arlad/inter.c3
-rw-r--r--usr.sbin/afs/src/arlad/messages.c79
-rw-r--r--usr.sbin/afs/src/arlad/poller.c5
-rw-r--r--usr.sbin/afs/src/arlad/ptest.c3
-rw-r--r--usr.sbin/afs/src/arlad/volcache.c6
8 files changed, 121 insertions, 40 deletions
diff --git a/usr.sbin/afs/src/arlad/cred.c b/usr.sbin/afs/src/arlad/cred.c
index 3b19bd5de7c..2f1b4e22ca3 100644
--- a/usr.sbin/afs/src/arlad/cred.c
+++ b/usr.sbin/afs/src/arlad/cred.c
@@ -224,7 +224,9 @@ recycle_entry (CredCacheEntry *ce)
void
cred_free (CredCacheEntry *ce)
-{
+{
+ if (ce == NULL)
+ return;
assert (ce->cell != CRED_ROOT_CELL);
--ce->refcount;
diff --git a/usr.sbin/afs/src/arlad/disco.c b/usr.sbin/afs/src/arlad/disco.c
index beb4522edea..eadee8a5f69 100644
--- a/usr.sbin/afs/src/arlad/disco.c
+++ b/usr.sbin/afs/src/arlad/disco.c
@@ -257,7 +257,10 @@ nop_chain(uint32_t disco_id, VenusFid *newparent,
* directory when connecting */
struct disco_rename *rn = (struct disco_rename *)buf;
- assert(sz == sizeof(struct disco_rename));
+ if (sz != sizeof(struct disco_rename)) {
+ arla_warnx(ADEBMISC, "sz != sizeof(struct disco_rename)");
+ exit(-1);
+ }
*newparent = rn->sourcepfid;
strlcpy(newname, rn->sourcename, namesz);
diff --git a/usr.sbin/afs/src/arlad/fcache.c b/usr.sbin/afs/src/arlad/fcache.c
index 4e316ff0dc4..b559ee1b2dd 100644
--- a/usr.sbin/afs/src/arlad/fcache.c
+++ b/usr.sbin/afs/src/arlad/fcache.c
@@ -673,7 +673,11 @@ throw_data (FCacheEntry *entry)
fcache_extra_file_name (entry, fname, sizeof(fname));
unlink (fname);
}
- assert(usedbytes >= entry->length);
+ if (usedbytes < entry->length) {
+ arla_warnx(ADEBCONN, "usedbytes %d < entry->length %d", usedbytes,
+ entry->length);
+ exit(-1);
+ }
/* XXX - things are wrong - continue anyway */
if (usedbytes < entry->length)
usedbytes = entry->length;
@@ -736,8 +740,11 @@ throw_entry (FCacheEntry *entry)
if (entry->flags.attrp && entry->host) {
ce = cred_get (entry->fid.Cell, 0, CRED_NONE);
- assert (ce != NULL);
-
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ exit(-1);
+ }
+
conn = conn_get (entry->fid.Cell, entry->host, afsport,
FS_SERVICE_ID, fs_probe, ce);
cred_free (ce);
@@ -918,7 +925,8 @@ cleaner (char *arg)
listdel (lrulist, item);
throw_entry (entry);
entry->lru_le = listaddtail (lrulist, entry);
- assert(entry->lru_le);
+ if(!entry->lru_le)
+ exit(-1);
ReleaseWriteLock (&entry->lock);
break;
}
@@ -1255,13 +1263,17 @@ fcache_recover_entry (struct fcache_store *st, void *ptr)
assert (cellid != -1);
ce = cred_get (cellid, 0, 0);
- assert (ce != NULL);
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ exit(-1);
+ }
res = volcache_getbyid (st->fid.Volume, cellid, ce, &vol, NULL);
cred_free (ce);
if (res)
return 0;
- assert(vol);
+ if (!vol)
+ exit(-1);
e = calloc(1, sizeof(FCacheEntry));
e->invalid_ptr = -1;
@@ -1303,13 +1315,15 @@ fcache_recover_entry (struct fcache_store *st, void *ptr)
e->flags.silly = FALSE;
e->tokens = 0;
e->parent.Cell = cell_name2num(st->parentcell);
- assert(e->parent.Cell != -1);
+ if (e->parent.Cell == -1)
+ exit(-1);
e->parent.fid = st->parent;
e->priority = st->priority;
e->hits = 0;
e->cleanergen = 0;
e->lru_le = listaddhead (lrulist, e);
- assert(e->lru_le);
+ if (!e->lru_le)
+ exit(-1);
e->volume = vol;
hashtabadd (hashtab, e);
if (e->length)
@@ -1411,7 +1425,8 @@ find_next_fs (fs_server_context *context,
context->conns[context->i - 1].ve_ent,
error);
} else if (prev_conn) {
- assert(prev_conn == context->conns[context->i - 1].conn);
+ if(prev_conn != context->conns[context->i - 1].conn)
+ exit(-1);
volcache_reliable_el(context->ve, context->conns[context->i - 1].ve_ent);
}
@@ -1639,7 +1654,8 @@ find_entry_nolock (VenusFid fid)
if (e != NULL) {
listdel (lrulist, e->lru_le);
e->lru_le = listaddhead (lrulist, e);
- assert(e->lru_le);
+ if(!e->lru_le)
+ return NULL;
}
return e;
}
@@ -2863,7 +2879,8 @@ create_file (FCacheEntry *dir_entry,
} else {
static int fakefid = 1001;
- assert(conn == NULL);
+ if (conn != NULL)
+ exit(-1);
ret = 0;
@@ -3009,7 +3026,8 @@ create_directory (FCacheEntry *dir_entry,
ret = 0;
- assert(conn == NULL);
+ if (conn != NULL)
+ exit(-1);
OutFid.Volume = dir_entry->fid.fid.Volume;
OutFid.Vnode = fakedir;
@@ -3574,7 +3592,10 @@ fcache_get (FCacheEntry **res, VenusFid fid, CredCacheEntry *ce)
}
e = find_free_entry ();
- assert (e != NULL);
+ if (e == NULL) {
+ arla_warnx(ADEBMISC, "find_free_entry failed");
+ return(-1);
+ }
old = find_entry (fid);
if (old) {
@@ -3582,9 +3603,11 @@ fcache_get (FCacheEntry **res, VenusFid fid, CredCacheEntry *ce)
ReleaseWriteLock (&e->lock);
e->lru_le = listaddtail (lrulist, e);
- assert(e->lru_le);
+ if (e->lru_le == NULL)
+ exit(-1);
- assert (old->flags.usedp);
+ if (!old->flags.usedp)
+ exit(-1);
*res = old;
return 0;
}
@@ -3617,7 +3640,8 @@ fcache_get (FCacheEntry **res, VenusFid fid, CredCacheEntry *ce)
e->tokens = 0;
memset (&e->parent, 0, sizeof(e->parent));
e->lru_le = listaddhead (lrulist, e);
- assert(e->lru_le);
+ if(!e->lru_le)
+ exit(-1);
e->invalid_ptr = -1;
e->volume = vol;
e->priority = fprio_get(fid);
diff --git a/usr.sbin/afs/src/arlad/inter.c b/usr.sbin/afs/src/arlad/inter.c
index 1d2420f2d2d..37b1c2aa52a 100644
--- a/usr.sbin/afs/src/arlad/inter.c
+++ b/usr.sbin/afs/src/arlad/inter.c
@@ -219,9 +219,6 @@ cm_open (FCacheEntry *entry, CredCacheEntry *ce, u_int tokens)
tokens);
mask = AREAD;
tokens |= NNPFS_DATA_R;
-#if 0
- assert(FALSE);
-#endif
}
if (checkright (entry, mask, ce)) {
diff --git a/usr.sbin/afs/src/arlad/messages.c b/usr.sbin/afs/src/arlad/messages.c
index a686caa4d7f..fa5848c8a57 100644
--- a/usr.sbin/afs/src/arlad/messages.c
+++ b/usr.sbin/afs/src/arlad/messages.c
@@ -314,7 +314,10 @@ try_again (int *ret, CredCacheEntry **ce, nnpfs_cred *cred, const VenusFid *fid)
cred_expire (*ce);
cred_free (*ce);
*ce = cred_get (cell, cred->pag, CRED_ANY);
- assert (*ce != NULL);
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ return FALSE;
+ }
return TRUE;
}
case RXKADSEALEDINCON :
@@ -403,7 +406,11 @@ nnpfs_message_getroot (int fd, struct nnpfs_message_getroot *h, u_int size)
int32_t cell_id = cell_name2num(cell_getthiscell());
ce = cred_get (cell_id, h->cred.pag, CRED_ANY);
- assert (ce != NULL);
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ ret = -1;
+ goto out;
+ }
do {
ret = getroot (&root_fid, ce);
} while (try_again (&ret, &ce, &h->cred, &root_fid));
@@ -466,8 +473,11 @@ nnpfs_message_getnode (int fd, struct nnpfs_message_getnode *h, u_int size)
(unsigned long)dirfid->fid.Unique, h->name);
ce = cred_get (dirfid->Cell, h->cred.pag, CRED_ANY);
- assert (ce != NULL);
-
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ ret = -1;
+ goto out;
+ }
ret = fcache_get(&dentry, *dirfid, ce);
if (ret)
goto out;
@@ -541,7 +551,11 @@ nnpfs_message_getattr (int fd, struct nnpfs_message_getattr *h, u_int size)
(unsigned long)fid.fid.Vnode,
(unsigned long)fid.fid.Unique);
ce = cred_get (fid.Cell, h->cred.pag, CRED_ANY);
- assert (ce != NULL);
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ ret = -1;
+ goto out;
+ }
ret = fcache_get(&entry, fid, ce);
if (ret)
@@ -600,7 +614,11 @@ nnpfs_message_putattr (int fd, struct nnpfs_message_putattr *h, u_int size)
(unsigned long)fid.fid.Unique);
nnpfs_attr2afsstorestatus(&h->attr, &status);
ce = cred_get (fid.Cell, h->cred.pag, CRED_ANY);
- assert (ce != NULL);
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ ret = -1;
+ goto out;
+ }
if (connected_mode != CONNECTED) {
ret = fcache_find (&entry, fid);
@@ -727,7 +745,11 @@ nnpfs_message_create (int fd, struct nnpfs_message_create *h, u_int size)
}
}
ce = cred_get (parent_fid.Cell, h->cred.pag, CRED_ANY);
- assert (ce != NULL);
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ ret = -1;
+ goto out;
+ }
ret = fcache_get(&dir_entry, parent_fid, ce);
if (ret)
@@ -874,7 +896,11 @@ nnpfs_message_mkdir (int fd, struct nnpfs_message_mkdir *h, u_int size)
(unsigned long)parent_fid.fid.Unique, h->name);
ce = cred_get (parent_fid.Cell, h->cred.pag, CRED_ANY);
- assert (ce != NULL);
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ ret = -1;
+ goto out;
+ }
nnpfs_attr2afsstorestatus(&h->attr, &store_status);
if (connected_mode != CONNECTED) {
@@ -1035,7 +1061,11 @@ nnpfs_message_link (int fd, struct nnpfs_message_link *h, u_int size)
h->name);
ce = cred_get (parent_fid.Cell, h->cred.pag, CRED_ANY);
- assert (ce != NULL);
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ ret = -1;
+ goto out;
+ }
ret = fcache_get(&dir_entry, parent_fid, ce);
if (ret)
@@ -1134,7 +1164,11 @@ nnpfs_message_symlink (int fd, struct nnpfs_message_symlink *h, u_int size)
(unsigned long)parent_fid.fid.Unique, h->name);
ce = cred_get (parent_fid.Cell, h->cred.pag, CRED_ANY);
- assert (ce != NULL);
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ ret = -1;
+ goto out;
+ }
nnpfs_attr2afsstorestatus(&h->attr, &store_status);
@@ -1153,7 +1187,11 @@ nnpfs_message_symlink (int fd, struct nnpfs_message_symlink *h, u_int size)
cred_free (ce);
ce = cred_get (dir_entry->fid.Cell, h->cred.pag, CRED_ANY);
- assert (ce != NULL);
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ ret = -1;
+ goto out;
+ }
if (ret)
goto out;
@@ -1248,7 +1286,11 @@ nnpfs_message_remove (int fd, struct nnpfs_message_remove *h, u_int size)
(unsigned long)parent_fid.fid.Unique, h->name);
ce = cred_get (parent_fid.Cell, h->cred.pag, CRED_ANY);
- assert (ce != NULL);
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ ret = -1;
+ goto out;
+ }
ret = fcache_get(&dir_entry, parent_fid, ce);
if (ret)
@@ -1329,7 +1371,6 @@ nnpfs_message_remove (int fd, struct nnpfs_message_remove *h, u_int size)
* Set datausedp since we push data to kernel in out:
*/
- assert(dir_entry->flags.attrusedp);
dir_entry->flags.datausedp = TRUE;
/*
@@ -1414,7 +1455,11 @@ nnpfs_message_rmdir (int fd, struct nnpfs_message_rmdir *h, u_int size)
(unsigned long)parent_fid.fid.Unique, h->name);
ce = cred_get (parent_fid.Cell, h->cred.pag, CRED_ANY);
- assert (ce != NULL);
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ ret = -1;
+ goto out;
+ }
/*
* Fetch the child-entry fid.
@@ -1845,7 +1890,11 @@ nnpfs_message_open (int fd, struct nnpfs_message_open *h, u_int size)
(unsigned long)fid.fid.Unique);
ce = cred_get (fid.Cell, h->cred.pag, CRED_ANY);
- assert (ce != NULL);
+ if (ce == NULL) {
+ arla_warnx (ADEBMISC, "cred_get failed");
+ ret = -1;
+ goto out;
+ }
ret = fcache_get(&entry, fid, ce);
if (ret)
diff --git a/usr.sbin/afs/src/arlad/poller.c b/usr.sbin/afs/src/arlad/poller.c
index 9af9003af0a..0d0b44a1cbd 100644
--- a/usr.sbin/afs/src/arlad/poller.c
+++ b/usr.sbin/afs/src/arlad/poller.c
@@ -266,7 +266,10 @@ poller (char *arg)
CredCacheEntry *ce;
ce = cred_get (e->cell, 0, CRED_NONE);
- assert (ce != NULL);
+ if (ce == NULL) {
+ arla_warnx(ADEBCONN, "cred_get failed - poller exiting");
+ exit(-1);
+ }
conn = conn_get (e->cell, e->server, afsport,
FS_SERVICE_ID, fs_probe, ce);
diff --git a/usr.sbin/afs/src/arlad/ptest.c b/usr.sbin/afs/src/arlad/ptest.c
index 42fa89f3318..3e6d4969962 100644
--- a/usr.sbin/afs/src/arlad/ptest.c
+++ b/usr.sbin/afs/src/arlad/ptest.c
@@ -127,7 +127,8 @@ main(int argc, char **argv)
while(number--) {
pe = poller_add_conn(&cce);
pe2 = poller_add_conn(&cce);
- assert(pe == pe2);
+ if (pe != pe2)
+ exit(-1);
poller_remove(pe);
poller_remove(pe2);
}
diff --git a/usr.sbin/afs/src/arlad/volcache.c b/usr.sbin/afs/src/arlad/volcache.c
index cbccbf48b72..577466e57b5 100644
--- a/usr.sbin/afs/src/arlad/volcache.c
+++ b/usr.sbin/afs/src/arlad/volcache.c
@@ -494,7 +494,10 @@ volcache_recover_entry (struct volcache_store *st, void *ptr)
struct vstore_context *c = (struct vstore_context *)ptr;
e->cell = cell_name2num (st->cell);
- assert (e->cell != -1);
+ if (e->cell != -1) {
+ arla_warnx(ADEBWARN, "can't resolve cell name");
+ return(-1);
+ }
e->entry = st->entry;
e->volsync = st->volsync;
e->refcount = st->refcount;
@@ -691,7 +694,6 @@ get_info_loop (VolCacheEntry *e, nvldbentry *entry,
"Cannot find any db servers in cell %d(%s) while "
"getting data for volume `%s'",
cell, cell_num2name(cell), name);
- assert (cell_is_sanep (cell));
return ENOENT;
}