chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(from parent 1:
2aae673
)
collect: realloc buffer, if needed
author
Xinwei Hu
<hxinwei@gmail.com>
Tue, 27 May 2008 17:35:03 +0000
(19:35 +0200)
committer
Kay Sievers
<kay.sievers@vrfy.org>
Tue, 27 May 2008 17:35:03 +0000
(19:35 +0200)
extras/collect/collect.c
patch
|
blob
|
history
diff --git
a/extras/collect/collect.c
b/extras/collect/collect.c
index 0a852f2db239b2d4050a3ec3b90371c273ddf3ee..feb0e7576871551e6e5984c32a0e43d51a79b9dc 100644
(file)
--- 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);
+ }
+ snprintf(buf, strlen(him->name)+2, "%s ", him->name);
write(fd, buf, strlen(buf));
}
}