Displaying 20 results from an estimated 53 matches for "ovector".
Did you mean:
vector
2014 Aug 11
2
[PATCH] p2v: check results of strndup and sscanf
...v/ssh.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/p2v/ssh.c b/p2v/ssh.c
index 1e9b05c..ff906df 100644
--- a/p2v/ssh.c
+++ b/p2v/ssh.c
@@ -505,7 +505,16 @@ open_data_connection (struct config *config, int *local_port, int *remote_port)
}, ovector, ovecsize)) {
case 100: /* Ephemeral port. */
port_str = strndup (&h->buffer[ovector[2]], ovector[3]-ovector[2]);
- sscanf (port_str, "%d", remote_port);
+ if (port_str == NULL) {
+ set_ssh_error ("not enough memory for strndup");
+...
2013 Oct 12
1
[PATCH] btrfs: Fix improper memmove usage in do_btrfs_subvolume_list
...trfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index c3247ac..765dec6 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -473,7 +473,7 @@ do_btrfs_subvolume_list (const mountable_t *fs)
#undef XSTRTOU64
- memmove (line, line + ovector[6], ovector[7] + 1);
+ memmove (line, line + ovector[6], ovector[7] - ovector[6] + 1);
this->btrfssubvolume_path = line;
}
--
1.8.3.1
2015 Jun 17
2
Re: [PATCH v4 2/3] do_btrfs_subvolume_list: fix a bad return value
...You don't need the change here, if later in the "error:" label you keep
the "if (ret)" condition.
> const char *errptr;
> @@ -530,20 +531,27 @@ do_btrfs_subvolume_list (const mountable_t *fs)
>
> #undef XSTRTOU64
>
> - memmove (line, line + ovector[6], ovector[7] - ovector[6] + 1);
> - this->btrfssubvolume_path = line;
> + this->btrfssubvolume_path =
> + strndup (line + ovector[6], ovector[7] - ovector[6]);
> + if (this->btrfssubvolume_path == NULL)
> + goto error;
> }
>
> - free (line...
2013 Jan 24
5
[PATCH] btrfs: Fix btrfs_subvolume_list on F18
...= 0; i < nr_subvolumes; ++i) {
/* To avoid allocations, reuse the 'line' buffer to store the
* path. Thus we don't need to free 'line', since it will be
* freed by the calling (XDR) code.
*/
char *line = lines[i];
+ #define N_MATCHES 3
+ int ovector[N_MATCHES * 3];
- if (sscanf (line, "ID %" SCNu64 " top level %" SCNu64 " path ",
- &ret->guestfs_int_btrfssubvolume_list_val[i].btrfssubvolume_id,
- &ret->guestfs_int_btrfssubvolume_list_val[i].btrfssubvolume_top_level_...
2015 Jun 17
6
[PATCH v4 0/3] btrfs: use CLEANUP_FREE_STRING_LIST for list free
As Pino's comment, we should take advantage of
macro CLEANUP_FREE_STRING_LIST
v4: remove some redundant strdup
v3: fix test case failure
v2: properly initialize lines
Chen Hanxiao (3):
do_btrfs_qgroup_show: fix a bad return value
do_btrfs_subvolume_list: fix a bad return value
btrfs: use CLEANUP_FREE_STRING_LIST for list free
daemon/btrfs.c | 70
2015 Jun 17
0
[PATCH v4 2/3] do_btrfs_subvolume_list: fix a bad return value
...gt;guestfs_int_btrfssubvolume_list_val == NULL) {
reply_with_perror ("malloc");
- goto error;
+ free (ret);
+ return NULL;
}
const char *errptr;
@@ -530,20 +531,27 @@ do_btrfs_subvolume_list (const mountable_t *fs)
#undef XSTRTOU64
- memmove (line, line + ovector[6], ovector[7] - ovector[6] + 1);
- this->btrfssubvolume_path = line;
+ this->btrfssubvolume_path =
+ strndup (line + ovector[6], ovector[7] - ovector[6]);
+ if (this->btrfssubvolume_path == NULL)
+ goto error;
}
- free (lines);
pcre_free (re);
return ret;...
2015 Jun 18
0
Re: [PATCH v4 2/3] do_btrfs_subvolume_list: fix a bad return value
...lution
I think the process in this patch should be a choice.
How do you think?
Regards,
- Chen
> > const char *errptr;
> > @@ -530,20 +531,27 @@ do_btrfs_subvolume_list (const mountable_t *fs)
> >
> > #undef XSTRTOU64
> >
> > - memmove (line, line + ovector[6], ovector[7] - ovector[6] + 1);
> > - this->btrfssubvolume_path = line;
> > + this->btrfssubvolume_path =
> > + strndup (line + ovector[6], ovector[7] - ovector[6]);
> > + if (this->btrfssubvolume_path == NULL)
> > + goto error;
> >...
2015 Jun 15
7
[PATCH v3 0/3] btrfs: use CLEANUP_FREE_STRING_LIST for list free
As Pino's comment, we should take advantage of
macro CLEANUP_FREE_STRING_LIST
v3: fix test case failure
v2: properly initialize lines
Chen Hanxiao (3):
do_btrfs_qgroup_show: fix a bad return value
do_btrfs_subvolume_list: fix a bad return value
btrfs: use CLEANUP_FREE_STRING_LIST for list free
daemon/btrfs.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
2015 Jun 18
2
[PATCH v5 1/2] do_btrfs_qgroup_show: fix a bad return value
We should not use temporary lines buffer as return value,
for lines buffer will be freed.
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
---
v5: modify according to Pino's comments
v4: take advantage of sscanf's '%m'.
v3: fix test case failure
daemon/btrfs.c | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git
2017 Jul 21
0
[PATCH v2 15/23] daemon: Reimplement ‘btrfs_subvolume_list’ and ‘btrfs_subvolume_get_default’ in OCaml.
...(i = 0; i < nr_subvolumes; ++i) {
- /* To avoid allocations, reuse the 'line' buffer to store the
- * path. Thus we don't need to free 'line', since it will be
- * freed by the calling (XDR) code.
- */
- char *line = lines[i];
-#define N_MATCHES 4
- int ovector[N_MATCHES * 3];
-
- if (pcre_exec (re_btrfs_subvolume_list, NULL, line, strlen (line), 0, 0,
- ovector, N_MATCHES * 3) < 0)
-#undef N_MATCHES
- {
- unexpected_output:
- reply_with_error ("unexpected output from 'btrfs subvolume list' command: %s",...
[PATCH 18/27] daemon: Reimplement ‘btrfs_subvolume_list’ and ‘btrfs_subvolume_get_default’ in OCaml.
2017 Jul 14
0
[PATCH 18/27] daemon: Reimplement ‘btrfs_subvolume_list’ and ‘btrfs_subvolume_get_default’ in OCaml.
...(i = 0; i < nr_subvolumes; ++i) {
- /* To avoid allocations, reuse the 'line' buffer to store the
- * path. Thus we don't need to free 'line', since it will be
- * freed by the calling (XDR) code.
- */
- char *line = lines[i];
-#define N_MATCHES 4
- int ovector[N_MATCHES * 3];
-
- if (pcre_exec (re_btrfs_subvolume_list, NULL, line, strlen (line), 0, 0,
- ovector, N_MATCHES * 3) < 0)
-#undef N_MATCHES
- {
- unexpected_output:
- reply_with_error ("unexpected output from 'btrfs subvolume list' command: %s",...
2017 Oct 11
0
[PATCH miniexpect 2/2] Add debugging capability at runtime.
..."usage: sshpass PASSWORD ssh [SSH-ARGS...] HOST\n");
+ exit (EXIT_FAILURE);
+}
+
int
main (int argc, char *argv[])
{
+ int opt;
+ int debug = 0;
mexp_h *h;
const char *password;
int status;
@@ -52,20 +63,31 @@ main (int argc, char *argv[])
const int ovecsize = 12;
int ovector[ovecsize];
- if (argc <= 3) {
- fprintf (stderr, "usage: sshpass PASSWORD ssh [SSH-ARGS...] HOST\n");
- exit (EXIT_FAILURE);
+ while ((opt = getopt (argc, argv, "d")) != -1) {
+ switch (opt) {
+ case 'd':
+ debug = 1;
+ break;
+ default:
+...
2015 Jun 15
0
[PATCH v3 2/3] do_btrfs_subvolume_list: fix a bad return value
...e_list (const mountable_t *fs)
{
- char **lines;
+ CLEANUP_FREE_STRING_LIST char **lines = NULL;
size_t i = 0;
const size_t MAX_ARGS = 64;
const char *argv[MAX_ARGS];
@@ -531,16 +531,16 @@ do_btrfs_subvolume_list (const mountable_t *fs)
#undef XSTRTOU64
memmove (line, line + ovector[6], ovector[7] - ovector[6] + 1);
- this->btrfssubvolume_path = line;
+ this->btrfssubvolume_path = strdup (line);
+ if (this->btrfssubvolume_path == NULL)
+ goto error;
}
- free (lines);
pcre_free (re);
return ret;
error:
- free_stringslen (lines, nr_subvol...
2015 Feb 02
0
Re: [PATCH 1/2] New API: btrfs_balance_status
...'.*' is (.*)", 0, &errptr, &erroffset, NULL);
> + if (re == NULL) {
> + reply_with_error ("pcre_compile (%i): %s", erroffset, errptr);
> + goto error;
> + }
> + if (pcre_exec (re, NULL, lines[0], strlen (lines[0]), 0, 0,
> + ovector, N_MATCH * 3) < 0) {
> + reply_with_error ("unexpected output from 'btrfs balance status' command: %s", lines[0]);
> + goto error;
> + }
> +#undef N_MATCH
> +
> + if (STREQ (lines[0] + ovector[2], "running"))
> + ret->btrfsbalance_st...
2017 Oct 11
5
[PATCH miniexpect 0/2] Add debugging capability at runtime.
Currently you can only turn on miniexpect debugging by recompiling.
These two patches make it configurable at runtime, and also improve
the usefulness of the output.
Rich.
2015 Feb 11
0
[PATCH v3 1/2] New API: btrfs_balance_status
...e_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ CLEANUP_FREE char *path_buf = NULL;
+ CLEANUP_FREE char *err = NULL;
+ char *out;
+ int r;
+ guestfs_int_btrfsbalance *ret;
+ char **lines;
+ size_t nlines;
+ const char *errptr;
+ int erroffset;
+#define N_MATCH 2
+ int ovector[N_MATCH * 3];
+ pcre *re = NULL;
+
+ path_buf = sysroot_path (path);
+ if (path_buf == NULL) {
+ reply_with_perror ("malloc");
+ return NULL;
+ }
+
+ ADD_ARG (argv, i, str_btrfs);
+ ADD_ARG (argv, i, "balance");
+ ADD_ARG (argv, i, "status");
+ ADD_ARG (a...
2015 Feb 13
0
[PATCH v4 1/2] New API: btrfs_balance_status
...e_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ CLEANUP_FREE char *path_buf = NULL;
+ CLEANUP_FREE char *err = NULL;
+ char *out;
+ int r;
+ guestfs_int_btrfsbalance *ret;
+ char **lines;
+ size_t nlines;
+ const char *errptr;
+ int erroffset;
+#define N_MATCH 2
+ int ovector[N_MATCH * 3];
+ pcre *re = NULL;
+
+ path_buf = sysroot_path (path);
+ if (path_buf == NULL) {
+ reply_with_perror ("malloc");
+ return NULL;
+ }
+
+ ADD_ARG (argv, i, str_btrfs);
+ ADD_ARG (argv, i, "balance");
+ ADD_ARG (argv, i, "status");
+ ADD_ARG (a...
2016 Feb 23
3
[PATCH 1/2] lib: Allow the COMPILE_REGEXP macro to be used everywhere.
Since the daemon links to pcre and use regular expressions, and since
the COMPILE_REGEXP macro doesn't depend on any aspects of the
library-side code (eg. the guestfs_h handle etc), we can allow the
daemon to use the COMPILE_REGEXP macro. Move the macro to
"guestfs-internal-all.h" to permit this.
---
src/guestfs-internal-all.h | 26 ++++++++++++++++++++++++++
src/guestfs-internal.h
2015 Feb 13
3
[PATCH v4 0/2] add btrfs_balance_status and btrfs_scrub_status
v4:
- add reply_with_error when nlines < 1
- remove `i == X' tests.
v3:
- rebase on upstream
- fix some comments
v2:
- add check for the length of lines[]
- the code parsing 'btrfs scrub -R status' output is changed into a loop
Hu Tao (2):
New API: btrfs_balance_status
New API: btfs_scrub_status
daemon/btrfs.c | 268
2015 Feb 13
1
Re: [PATCH v4 1/2] New API: btrfs_balance_status
...ze_t i = 0;
> + CLEANUP_FREE char *path_buf = NULL;
> + CLEANUP_FREE char *err = NULL;
> + char *out;
> + int r;
> + guestfs_int_btrfsbalance *ret;
> + char **lines;
> + size_t nlines;
> + const char *errptr;
> + int erroffset;
> +#define N_MATCH 2
> + int ovector[N_MATCH * 3];
> + pcre *re = NULL;
> +
> + path_buf = sysroot_path (path);
> + if (path_buf == NULL) {
> + reply_with_perror ("malloc");
> + return NULL;
> + }
> +
> + ADD_ARG (argv, i, str_btrfs);
> + ADD_ARG (argv, i, "balance");
>...