On Tue, May 27, 2008 at 04:08:23PM +0200, Xinwei Hu wrote: > Hi everyone, > > The attached patch fixed a issue with collect when very long IDs are > used for the first time. > > Please consider it for upstream. > > Thanks. > diff --git a/extras/collect/collect.c b/extras/collect/collect.c > index 0a852f2..feb0e75 100644 > --- a/extras/collect/collect.c > +++ b/extras/collect/collect.c > @@ -271,7 +271,11 @@ static int missing(int fd) > if (him->state == STATE_NONE) { > ret++; > } else { > - sprintf(buf, "%s ", him->name); > + while (strlen(him->name)+1 >= bufsize) { > + bufsize = bufsize << 1; > + buf = realloc(buf, bufsize); > + } while() ? bufsize <<= ((bufsize + strlen(him->name) + 1) / bufsize - 1); buf = realloc(buf, bufsize); > + snprintf(buf, strlen(him->name)+2, "%s ", him->name); > write(fd, buf, strlen(buf)); Can't we write directly to the file? Something like: write(fd, him->name, strlen(him->name)); write(fd, " ", 1); Karel -- Karel Zak <kzak@xxxxxxxxxx> -- To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html