search for: add_string_nodup

Displaying 20 results from an estimated 48 matches for "add_string_nodup".

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...
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.
2016 Jul 07
0
[PATCH 2/2] daemon: fix cleanup of stringsbuf usages
...EANUP_FREE_STRINGSBUF DECLARE_STRINGSBUF (ret); - if (add_string (&ret, "TYPE") == -1) goto error; + if (add_string (&ret, "TYPE") == -1) return NULL; s = get_blkid_tag (device, "TYPE"); - if (s == NULL) goto error; + if (s == NULL) return NULL; if (add_string_nodup (&ret, s) == -1) - goto error; + return NULL; - if (add_string (&ret, "LABEL") == -1) goto error; + if (add_string (&ret, "LABEL") == -1) return NULL; s = get_blkid_tag (device, "LABEL"); - if (s == NULL) goto error; + if (s == NULL) return N...
2011 Nov 11
3
[PATCH v2] Add mdadm-create, list-md-devices APIs.
This adds the mdadm-create API for creating RAID devices, and includes various fixes for the other two patches. Rich.
2011 Dec 05
1
[PATCH] blkid: split the RHEL5 which can't support some options
...&size, &alloc, get_blkid_tag(device, "LABEL")) == -1) + goto error; + if (add_string(&ret, &size, &alloc, "UUID") == -1) goto error; + if (add_string(&ret, &size, &alloc, get_blkid_tag(device, "UUID")) == -1) + goto error; + if (add_string_nodup(&ret, &size, &alloc, NULL) == -1) goto error; + + return ret; +error: + if (ret) free_strings(ret); + return NULL; +} + +char ** +do_blkid(const char *device) +{ + int r; + char *out = NULL, *err = NULL; + char **lines = NULL; + + char **ret = NULL; + int size = 0, alloc = 0; +...
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
2017 Apr 19
1
[PATCH] daemon: Remove use of fixed-size stack buffers.
GCC 7 complains that the fixed size buffers are not large enough (at least in theory) when using ‘-O3 -mtune=broadwell’. --- daemon/devsparts.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/daemon/devsparts.c b/daemon/devsparts.c index 584e7d8b8..eac79197e 100644 --- a/daemon/devsparts.c +++ b/daemon/devsparts.c @@ -125,13 +125,16 @@ foreach_block_device
2017 Apr 19
2
[PATCH v2] daemon: Remove use of fixed-size stack buffers.
v1 -> v2: - Fixes as suggested by Pino. Rich.
2017 Apr 19
0
[PATCH v2] daemon: Remove use of fixed-size stack buffers.
...char dev_path[256]; - snprintf (dev_path, sizeof dev_path, "/dev/%s", device); + char *dev_path; - if (add_string (r, dev_path) == -1) { + if (asprintf (&dev_path, "/dev/%s", device) == -1) { + reply_with_perror ("asprintf"); return -1; } + if (add_string_nodup (r, dev_path) == -1) + return -1; + return 0; } @@ -153,10 +156,13 @@ do_list_devices (void) static int add_partitions (const char *device, struct stringsbuf *r) { - char devdir[256]; + CLEANUP_FREE char *devdir = NULL; /* Open the device's directory under /sys/block */ - sn...
2020 Mar 16
0
[PATCH libguestfs v2 2/3] daemon: Add filter_list utility function.
...tr) == true>. + * + * B<Note> it does not copy the strings, be careful not to 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
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.
2014 Dec 02
0
[PATCH 2/8] New API: btrfs_subvolume_show
...ULL; + + if (ss_len != 0) + ss[ss_len++] = ','; + + memcpy (ss + ss_len, key, strlen (key)); + ss_len += strlen (key); + ss[ss_len] = '\0'; + + p = analyze_line(p, &key, &value); + } + + if (ss) { + if (add_string_nodup (&ret, ss) == -1) { + free (ss); + return NULL; + } + } else { + if (add_string (&ret, "") == -1) + return NULL; + } + } else { + if (add_string (&ret, key ? key : "") == -1) + return NULL; + if (...
2015 Jun 17
4
[PATCH 1/4] daemon: introduce free_stringsbuf
...xtern 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/daemon/guestfsd.c @@ -587,6 +587,13 @@ end_stringsbuf (struct stringsbuf *sb) return add_string_nodup (sb, NULL); } +void +free_stringsbuf (struct stringsbuf *sb) +{ + if (sb->argv != NULL) + free_stringslen (sb->argv, sb->size); +} + size_t count_strings (char *const *argv) { -- 2.1.0
2014 Dec 05
1
Re: [PATCH 2/8] New API: btrfs_subvolume_show
...[ss_len++] = ','; > + > + memcpy (ss + ss_len, key, strlen (key)); > + ss_len += strlen (key); > + ss[ss_len] = '\0'; > + > + p = analyze_line(p, &key, &value); > + } > + > + if (ss) { > + if (add_string_nodup (&ret, ss) == -1) { > + free (ss); > + return NULL; > + } > + } else { > + if (add_string (&ret, "") == -1) > + return NULL; > + } > + } else { > + if (add_string (&ret, key ? key : "&qu...
2014 Nov 21
3
Re: [PATCH 6/6] New API: btrfs_subvolume_show
...length_of_ss + 1, p, strlen (p)); > + } else { > + ss = strdup(p); Missing check for failed strdup. > + } > + > + p = pend; > + } > + > + if (ss) { > + if (add_string (&ret, ss) == -1) { This needs to be add_string_nodup. > + free(ss); No need to free ss here; theoretically add_string will take care of it, be it added to the stringbuf or freed on error. > + return NULL; > + } > + } > + else { > + if (add_string (&ret, strdup(""...
2020 Mar 16
0
[PATCH libguestfs v2 1/3] daemon: xattr: Refactor code which splits attr names from the kernel.
...urned list contains pointers to the original + * strings in C<buf> so be careful that you do not double-free them. + */ +static char ** +split_attr_names (char *buf, size_t len) +{ + size_t i; + DECLARE_STRINGSBUF (ret); + + for (i = 0; i < len; i += strlen (&buf[i]) + 1) { + if (add_string_nodup (&ret, &buf[i]) == -1) + return NULL; + } + if (end_stringsbuf (&ret) == -1) + return NULL; + + return take_stringsbuf (&ret); +} + static int compare_xattrs (const void *vxa1, const void *vxa2) { @@ -106,7 +132,8 @@ getxattrs (const char *path, { ssize_t len, vlen...
2014 Nov 24
0
Re: [PATCH 6/6] New API: btrfs_subvolume_show
...> + ss = strdup(p); > > Missing check for failed strdup. > > > + } > > + > > + p = pend; > > + } > > + > > + if (ss) { > > + if (add_string (&ret, ss) == -1) { > > This needs to be add_string_nodup. > > > + free(ss); > > No need to free ss here; theoretically add_string will take care of it, > be it added to the stringbuf or freed on error. This is fail case. > > > + return NULL; > > + } > > + } > > +...
2017 Aug 03
9
[PATCH 0/6] tests: Fix handling of device API parameters (RHBZ#1477623).
https://bugzilla.redhat.com/show_bug.cgi?id=1477623 The first two patches are cleanups. The third patch changes the way that we handle Device and Dev_or_Path parameters so that a parameter marked as such can really only contain a block device name (and not, for instance, a chardev). Using a chardev here caused hangs in the API. The next two patches fix API usage to conform to this new stricter
2014 Nov 26
7
[PATCH v2 0/5] btrfs support part1: subvolume commands
Hi, This is the part1 of improving btrfs support. This series adds missing parameters to btrfs_subvolume_snapshot and btrfs_subvolume_create, and adds two new API btrfs_subvolume_get_default and btrfs_subvolume_show. Other parts will follow. Regards, Hu changes: v2: - add 'once_had_no_optargs = true' for btrfs_subvolume_snapshot and btrfs_subvolume_create - improved documents
2016 Feb 23
4
[PATCH v3 0/4] [FOR COMMENTS ONLY] Rework inspection.
Previously posted: https://www.redhat.com/archives/libguestfs/2015-December/msg00038.html Inspection now really succeeds on a small number of simple guests. To test it out: $ ./run guestfish -v -x -a /tmp/centos-6.img ><fs> run ><fs> debug sh "guestfs-inspection --verbose" Rich.