From: Andre Date: Mon, 29 May 2006 22:56:35 +0000 (+0200) Subject: wng: fix two critical bugs X-Git-Tag: v0.2.14~99 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=b23afbb1d859a79a2682a80420a7f3c693b210e6;p=paraslash.git wng: fix two critical bugs the open functions of the writers in a writer node group might be interested to know which group they belong to. Unfortunately, the old code called open before initializing the "wng" pointer of the writer node. The second bug triggers for example if invalid receiver options are given. In this case wng_close() is called with a NULL-argument as the wng has not been opened yet. The solution is to check for NULL pointers and return immediately in this case. --- diff --git a/write_common.c b/write_common.c index cfdabe48..39f124f8 100644 --- a/write_common.c +++ b/write_common.c @@ -58,15 +58,15 @@ int wng_open(struct writer_node_group *g) { int i, ret = 1; - PARA_NOTICE_LOG("opening wng with %d writer(s)\n", g->num_writers); + PARA_NOTICE_LOG("opening wng %p with %d writer(s)\n", g, g->num_writers); FOR_EACH_WRITER_NODE(i, g) { struct writer_node *wn = &g->writer_nodes[i]; + wn->wng = g; ret = wn->writer->open(wn); if (ret < 0) goto out; wn->chunk_bytes = ret; g->max_chunk_bytes = PARA_MAX(g->max_chunk_bytes, ret); - wn->wng = g; PARA_DEBUG_LOG("pre_select: %p\n", &wn->writer->pre_select); PARA_DEBUG_LOG("post_select: %p\n", &wn->writer->post_select); wn->task.pre_select = wn->writer->pre_select; @@ -94,6 +94,8 @@ void wng_close(struct writer_node_group *g) { int i; + if (!g) + return; PARA_NOTICE_LOG("closing wng with %d writer(s)\n", g->num_writers); FOR_EACH_WRITER_NODE(i, g) { struct writer_node *wn = &g->writer_nodes[i];