search for: end_stringsbuf

Displaying 20 results from an estimated 77 matches for "end_stringsbuf".

2016 Jul 07
0
[PATCH 2/2] daemon: fix cleanup of stringsbuf usages
...fbb71..a9e36d1 100644 --- a/daemon/9p.c +++ b/daemon/9p.c @@ -41,7 +41,7 @@ static char *read_whole_file (const char *filename); char ** do_list_9p (void) { - DECLARE_STRINGSBUF (r); + CLEANUP_FREE_STRINGSBUF DECLARE_STRINGSBUF (r); DIR *dir; @@ -60,7 +60,7 @@ do_list_9p (void) if (end_stringsbuf (&r) == -1) return NULL; - return r.argv; + return take_stringsbuf (&r); } while (1) { @@ -93,7 +93,6 @@ do_list_9p (void) /* Check readdir didn't fail */ if (errno != 0) { reply_with_perror ("readdir: /sys/block"); - free_stringslen (r.arg...
2016 Jul 07
2
[PATCH 1/2] daemon: free the string on stringsbuf add failure
If add_string_nodup fails free the passed string instead of leaking it, as that string would have been owned by the stringbuf. Adapt few places to this behaviour. --- daemon/btrfs.c | 4 +--- daemon/devsparts.c | 8 ++++---- daemon/guestfsd.c | 1 + 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/daemon/btrfs.c b/daemon/btrfs.c index 9b52aa8..d70565a 100644 ---
2015 Jun 17
4
[PATCH 1/4] daemon: introduce free_stringsbuf
...n.h b/daemon/daemon.h index 53cb797..bed4dbc 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -92,6 +92,7 @@ extern int add_string (struct stringsbuf *sb, const char *str); extern int add_sprintf (struct stringsbuf *sb, const char *fs, ...) __attribute__((format (printf,2,3))); extern int end_stringsbuf (struct stringsbuf *sb); +extern void free_stringsbuf (struct stringsbuf *sb); extern size_t count_strings (char *const *argv); extern void sort_strings (char **argv, size_t len); diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index c912ee3..453dee1 100644 --- a/daemon/guestfsd.c +++ b/daem...
2012 Mar 13
2
[PATCH 0/2] 'int' to 'size_t' changes
These two patches are probably not completely independent, but separating them is a lot of work. With *both* patches applied, all the tests and extra-tests pass. That's no guarantee however that there isn't a mistake, so I don't think this patch is a candidate for the 1.16 branch, until it's had a lot more testing in development. Rich.
2015 Jun 17
0
[PATCH 4/4] daemon: add split_lines_sb
...{ DECLARE_STRINGSBUF (lines); + DECLARE_STRINGSBUF (null); char *p, *pend; - if (STREQ (str, "")) - return empty_list (); + if (STREQ (str, "")) { + /* No need to check the return value, as the stringsbuf will be + * returned as it is anyway. + */ + end_stringsbuf (&lines); + return lines; + } p = str; while (p) { @@ -1155,16 +1164,26 @@ split_lines (char *str) } if (add_string (&lines, p) == -1) { - return NULL; + free_stringsbuf (&lines); + return null; } p = pend; } - if (end_stringsbuf...
2017 Mar 06
7
[PATCH 0/6] Various Coverity fixes #2
Hi, this patch series fixes few more issues discovered by Coverity. Thanks, Pino Toscano (6): tail: check the return value pf guestfs_set_pgroup daemon: btrfs: check end_stringsbuf return values everywhere java: use cleanup handlers for structs (lists) as return values lib: qemu: improve handling of FILE* p2v: check more return values p2v: fix possible close(-1) issue cat/tail.c | 5 ++- daemon/btrfs.c | 3 +- generator/java.ml | 8 ++--- lib/qemu.c...
2017 Jul 14
0
[PATCH 23/27] daemon: Reimplement ‘md_detail’ API in OCaml.
...ring (&ret, eq) == -1) return NULL; - } else { - /* Ignore lines with no equals sign (shouldn't happen). Log to stderr so - * it will show up in LIBGUESTFS_DEBUG. */ - fprintf (stderr, "md-detail: unexpected mdadm output ignored: %s", line); - } - } - - if (end_stringsbuf (&ret) == -1) - return NULL; - - return take_stringsbuf (&ret); -} - int do_md_stop (const char *md) { diff --git a/daemon/md.ml b/daemon/md.ml index caf87cf8f..ba045b5f7 100644 --- a/daemon/md.ml +++ b/daemon/md.ml @@ -46,3 +46,40 @@ let list_md_devices () = (* Return the list...
2016 Jan 27
4
[PATCH] lvm: support lvm2 older than 2.02.107
...+ + snprintf (buf, sizeof buf, "/dev/%s/%s", vg_name, lv_name); + if (add_string (&ret, buf) == -1) { + free (out); + return NULL; + } + } + + p = pend; + } + + free (out); + + if (ret.size > 0) + sort_strings (ret.argv, ret.size); + + if (end_stringsbuf (&ret) == -1) + return NULL; + + return ret.argv; +} + char ** do_pvs (void) { @@ -139,26 +219,76 @@ do_vgs (void) return convert_lvm_output (out, NULL); } +/* Check whether lvs has -S to filter its output. + * It is available only in lvm2 >= 2.02.107. + */ +static int +test_lvs...
2015 Jun 19
2
[PATCH v2 1/2] Modify the function: analyze_line, make it more flexible
Mofify the function from a fixed delimiter to a variable. So, it can be used in more APIs later. Also modified the existing callers Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com> --- daemon/btrfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/daemon/btrfs.c b/daemon/btrfs.c index 39392f7..caa28ca 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@
2014 Aug 26
6
[PATCH 0/3] fix setting lvm filter with newer lvm2
Hi, newer lvm2 releases don't have have uncommented "filter" lines, so the current way to edit lvm.conf doesn't work anymore. Instead, switch to augeas (with a "custom" len) for a cleaner and working way to set the lvm filter. Pino Toscano (3): daemon: add add_sprintf daemon: move AUGEAS_ERROR to the common header daemon: lvm-filter: use augeas for setting the
2015 Jun 19
3
[PATCH v3 1/2] Modify the function: analyze_line, make it more flexible
Mofify the function from a fixed delimiter to a variable. So, it can be used in more APIs later. Also modified the existing callers Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com> --- daemon/btrfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/daemon/btrfs.c b/daemon/btrfs.c index 39392f7..caa28ca 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@
2015 Jun 19
0
[PATCH v2 2/2] New API: btrfs_device_stats
...value". */ + p = analyze_line(out, &key, &value, ' '); + while (key) { + if (add_string (&ret, key) == -1) + goto error; + + if (add_string (&ret, value) == -1) + goto error; + + p = analyze_line(p, &key, &value, ' '); + } + + if (end_stringsbuf (&ret) == -1) + goto error; + + return ret.argv; + +error: + if (ret.argv != NULL) + free_stringslen (ret.argv, ret.size); + + return NULL; +} diff --git a/generator/actions.ml b/generator/actions.ml index d5e5ccf..8d279fd 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@...
2015 Jun 19
0
[PATCH v3 2/2] New API: btrfs_device_stats
...value". */ + p = analyze_line(out, &key, &value, ' '); + while (key) { + if (add_string (&ret, key) == -1) + goto error; + + if (add_string (&ret, value) == -1) + goto error; + + p = analyze_line(p, &key, &value, ' '); + } + + if (end_stringsbuf (&ret) == -1) + goto error; + + return ret.argv; + +error: + if (ret.argv != NULL) + free_stringslen (ret.argv, ret.size); + + return NULL; +} diff --git a/generator/actions.ml b/generator/actions.ml index d5e5ccf..8d279fd 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@...
2020 Mar 12
0
[PATCH libguestfs 2/3] daemon: Add filter_list utility function.
...re C<p (str) != 0>. + */ +char ** +filter_list (int (*p) (const char *str), char **strs) +{ + DECLARE_STRINGSBUF (ret); + size_t i; + + for (i = 0; strs[i] != NULL; ++i) { + if (p (strs[i]) != 0) { + if (add_string (&ret, strs[i]) == -1) + return NULL; + } + } + if (end_stringsbuf (&ret) == -1) + return NULL; + + return take_stringsbuf (&ret); +} + /** * Skip leading and trailing whitespace, updating the original string * in-place. -- 2.25.0
2020 Mar 16
0
[PATCH libguestfs v2 2/3] daemon: Add filter_list utility function.
...o double-free + * them. + */ +char ** +filter_list (bool (*p) (const char *str), char **strs) +{ + DECLARE_STRINGSBUF (ret); + size_t i; + + for (i = 0; strs[i] != NULL; ++i) { + if (p (strs[i])) { + if (add_string_nodup (&ret, strs[i]) == -1) + return NULL; + } + } + if (end_stringsbuf (&ret) == -1) + return NULL; + + return take_stringsbuf (&ret); +} + /** * Skip leading and trailing whitespace, updating the original string * in-place. -- 2.25.0
2014 Sep 23
0
[PATCH 09/13] syntax-check: fix prohibit_path_max_allocation check
...+ if (buf == NULL) { + reply_with_perror ("malloc"); + goto error; + } + while (fgets (buf, sizeof buf, fp) != NULL) { size_t len = strlen (buf); @@ -374,6 +380,8 @@ do_inotify_files (void) fclose (fp); /* implicitly closes fd */ fp = NULL; + free(buf); + if (end_stringsbuf (&ret) == -1) goto error; @@ -384,6 +392,8 @@ do_inotify_files (void) if (fp != NULL) fclose (fp); + free (buf); + unlink (tempfile); return NULL; } -- 1.9.3
2016 Jan 28
0
[PATCH v2] lvm: support lvm2 older than 2.02.107
...+ + snprintf (buf, sizeof buf, "/dev/%s/%s", vg_name, lv_name); + if (add_string (&ret, buf) == -1) { + free (out); + return NULL; + } + } + + p = pend; + } + + free (out); + + if (ret.size > 0) + sort_strings (ret.argv, ret.size); + + if (end_stringsbuf (&ret) == -1) + return NULL; + + return ret.argv; +} + char ** do_pvs (void) { @@ -139,26 +218,72 @@ do_vgs (void) return convert_lvm_output (out, NULL); } +/* Check whether lvs has -S to filter its output. + * It is available only in lvm2 >= 2.02.107. + */ +static int +test_lvs...
2014 Nov 21
0
[PATCH 6/6] New API: btrfs_subvolume_show
...+ if (add_string (&ret, colon) == -1) { + return NULL; + } + } + else { + if (add_string (&ret, p) == -1) { + return NULL; + } + if (add_string (&ret, "") == -1) { + return NULL; + } + } + + p = pend; + } + + if (end_stringsbuf (&ret) == -1) + return NULL; + + return ret.argv; + +} diff --git a/generator/actions.ml b/generator/actions.ml index cf96039..24d3ecc 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -12014,6 +12014,15 @@ This is the internal call which implements C<guestfs_lstatnslist&gt...
2020 Mar 16
6
[PATCH libguestfs v2 0/3] daemon: Fix various commands which break on NTFS-3g compressed files.
v1 here: https://www.redhat.com/archives/libguestfs/2020-March/msg00099.html This one fixes most of the points picked up in review, and does not strdup the strings which should keep down memory usage if that is a concern. Rich.
2016 May 12
1
[PATCH] New API: btrfs-filesystem-show (RHBZ#1164765)
...ome devices missing")) { + reply_with_error_errno (ENODEV, "%s: missing devices", device); + return NULL; + } else { + reply_with_error ("unrecognized line in output from 'btrfs filesystem show': %s", lines[i]); + return NULL; + } + } + + end_stringsbuf (&ret); + + return take_stringsbuf (&ret); +} + /* btrfs command add a new command * inspect-internal min-dev-size <path> * since v4.2 diff --git a/generator/actions.ml b/generator/actions.ml index e5cb939..3566371 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@...