projects
/
splice.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
648a7fe
)
[PATCH] vmsplice2: don't allocate memory on stack
author
Jens Axboe
<axboe@suse.de>
Tue, 2 May 2006 11:13:12 +0000
(13:13 +0200)
committer
Jens Axboe
<axboe@suse.de>
Tue, 2 May 2006 11:13:12 +0000
(13:13 +0200)
vmsplice2.c
patch
|
blob
|
blame
|
history
diff --git
a/vmsplice2.c
b/vmsplice2.c
index 189846eb7737899f3822f78c55206425c1685ea6..f4182ed160d330184931e5488716847392bd5b6c 100644
(file)
--- a/
vmsplice2.c
+++ b/
vmsplice2.c
@@
-57,19
+57,31
@@
static int usage(char *name)
return 1;
}
return 1;
}
+#define S1 "header header header header header header header header"
+#define S2 "body body body body body body body body body body body"
+#define S3 "footer footer footer footer footer footer footer footer"
+
int main(int argc, char *argv[])
{
int main(int argc, char *argv[])
{
- char h[] = "header header header header header header header header";
- char b[] = "body body body body body body body body body body body";
- char f[] = "footer footer footer footer footer footer footer footer";
struct iovec vecs[3];
struct iovec vecs[3];
+#if 0
+ /* Dangerous on-stack usage! */
+ char h[] = S1;
+ char b[] = S2;
+ char f[] = S3;
vecs[0].iov_base = h;
vecs[0].iov_base = h;
- vecs[0].iov_len = strlen(h);
vecs[1].iov_base = b;
vecs[1].iov_base = b;
- vecs[1].iov_len = strlen(b);
vecs[2].iov_base = f;
vecs[2].iov_base = f;
- vecs[2].iov_len = strlen(f);
+#else
+ vecs[0].iov_base = strdup(S1);
+ vecs[1].iov_base = strdup(S2);
+ vecs[2].iov_base = strdup(S3);
+
+ vecs[0].iov_len = strlen(vecs[0].iov_base);
+ vecs[1].iov_len = strlen(vecs[1].iov_base);
+ vecs[2].iov_len = strlen(vecs[2].iov_base);
+#endif
if (check_output_pipe())
return usage(argv[0]);
if (check_output_pipe())
return usage(argv[0]);