search for: safe_strndup

Displaying 20 results from an estimated 44 matches for "safe_strndup".

Did you mean: safe_strdup
2013 Jun 05
3
[PATCH 1/3] inspection: Refactor windows systemroot detection to allow re-use
This change refactors guestfs___has_windows_systemroot to guestfs___get_windows_systemroot. The new function returns a dynamically allocated char * which must be freed. The new function is no less efficient than before, as it returns the result of guestfs___case_sensitive_path_silently, which is required anyway. The new code is slightly more efficient than before, as it re-uses the result of this
2013 Nov 05
2
[PATCH stable-1.24] Fix fstab block device resolution for FreeBSD
...**ret1, char **ret2, char **ret3, char **ret4) +{ + size_t len = strlen (str); + int vec[30], r; + + r = pcre_exec (re, NULL, str, len, 0, 0, vec, 30); + if (r == PCRE_ERROR_NOMATCH) + return 0; + + *ret1 = NULL; + *ret2 = NULL; + *ret3 = NULL; + *ret4 = NULL; + + if (r > 1) *ret1 = safe_strndup (g, &str[vec[2]], vec[3]-vec[2]); + if (r > 2) *ret2 = safe_strndup (g, &str[vec[4]], vec[5]-vec[4]); + if (r > 3) *ret3 = safe_strndup (g, &str[vec[6]], vec[7]-vec[6]); + if (r > 4) *ret4 = safe_strndup (g, &str[vec[8]], vec[9]-vec[8]); + + return 1; +} + /* Match a r...
2013 Nov 03
2
[PATCH stable-1.24] Fix fstab block device resolution for FreeBSD
...**ret1, char **ret2, char **ret3, char **ret4) +{ + size_t len = strlen (str); + int vec[30], r; + + r = pcre_exec (re, NULL, str, len, 0, 0, vec, 30); + if (r == PCRE_ERROR_NOMATCH) + return 0; + + *ret1 = NULL; + *ret2 = NULL; + *ret3 = NULL; + *ret4 = NULL; + + if (r > 1) *ret1 = safe_strndup (g, &str[vec[2]], vec[3]-vec[2]); + if (r > 2) *ret2 = safe_strndup (g, &str[vec[4]], vec[5]-vec[4]); + if (r > 3) *ret3 = safe_strndup (g, &str[vec[6]], vec[7]-vec[6]); + if (r > 4) *ret4 = safe_strndup (g, &str[vec[8]], vec[9]-vec[8]); + + return 1; +} + /* Match a r...
2012 Oct 29
1
[PATCH] lib: update inspect_list_applications to return all installed RPMs (RHBZ#859885)
...stances of + * that pacakge. For example, if glibc.i686 and glibc.x86_64 are + * both installed, then there will be a link for each Packages + * entry. Add an entry onto list for all installed instances. + */ + for (link_p = value; link_p < value + valuelen; link_p += 8) { + name = safe_strndup (g, key, keylen); + + list->names = safe_realloc (g, list->names, + (list->len + 1) * sizeof (struct rpm_name)); + list->names[list->len].name = name; + memcpy (list->names[list->len].link, link_p, 4); + list->len++; + } retur...
2012 Oct 15
1
[PATCH for discussion] lib: update inspect_list_applications to return app_arch
Here's a partially implemented fix for RHBZ#859949. Seeing as this is my first libguestfs patch, I'd like some other eyeballs on it to make sure I've not done anything completely crazy. If the rpm case looks ok, I'll update the deb and windows cases if/where applicable.
2016 Feb 05
3
[PATCH] inspect: get windows drive letters for GPT disks.
...disk and partition. */ - device = map_registry_disk_blob (g, blob); + if (is_gpt) + device = map_registry_disk_blob_gpt (g, blob); + else + device = map_registry_disk_blob (g, blob); + if (device != NULL) { fs->drive_mappings[count++] = safe_strndup (g, &key[12], 1); fs->drive_mappings[count++] = device; @@ -605,6 +614,91 @@ map_registry_disk_blob (guestfs_h *g, const void *blob) return safe_asprintf (g, "%s%d", devices[i], partitions->val[j].part_num); } +/* Matches Windows registry HKLM\SYSYTEM\MountedDev...
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.
2013 Sep 06
1
[PATCH] arm: appliance: Add support for device trees (dtb's).
This is the libguestfs companion patch to: https://www.redhat.com/archives/libguestfs/2013-September/msg00045.html Rich.
2016 Feb 05
2
[PATCHv2] inspect: get windows drive letters for GPT disks.
...disk and partition. */ - device = map_registry_disk_blob (g, blob); + if (is_gpt) + device = map_registry_disk_blob_gpt (g, blob); + else + device = map_registry_disk_blob (g, blob); + if (device != NULL) { fs->drive_mappings[count++] = safe_strndup (g, &key[12], 1); fs->drive_mappings[count++] = device; @@ -605,6 +615,96 @@ map_registry_disk_blob (guestfs_h *g, const void *blob) return safe_asprintf (g, "%s%d", devices[i], partitions->val[j].part_num); } +/* Matches Windows registry HKLM\SYSYTEM\MountedDev...
2017 May 04
0
Re: [PATCH v1 1/2] appliance: search all types of appliances for each path separately
...y with > + * libguestfs < 1.5.4). > + */ > + do { > + size_t len = strcspn (pelem, PATH_SEPARATOR); > + /* Empty element or "." means current directory. */ > + char *path = (len == 0) ? safe_strdup (g, ".") : > + safe_strndup (g, pelem, len); Better to use: CLEANUP_FREE char *path = ... etc ... and drop the call to free (path) just after. The rest looks fine to me. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.word...
2016 Mar 29
3
[PATCH 0/2] added filesystem_walk API
The filesystem_walk API parses the FS internals of a partition and returns a list of all the files and directories contained within. It list deleted files and directories as well. For each node, it reports its relative path, its inode and its allocation status. This is the end user API for inspecting a disk partition content. The command can handle filenames with special characters. Example
2016 Feb 05
0
Re: [PATCH] inspect: get windows drive letters for GPT disks.
...vice = map_registry_disk_blob (g, blob); > + if (is_gpt) > + device = map_registry_disk_blob_gpt (g, blob); > + else > + device = map_registry_disk_blob (g, blob); > + > if (device != NULL) { > fs->drive_mappings[count++] = safe_strndup (g, &key[12], 1); > fs->drive_mappings[count++] = device; > @@ -605,6 +614,91 @@ map_registry_disk_blob (guestfs_h *g, const void *blob) > return safe_asprintf (g, "%s%d", devices[i], partitions->val[j].part_num); > } > > +/* Matches Windows re...
2015 Sep 09
2
[PATCH] inspect: try to use /etc/os-release on Linux guests
...tro = OS_DISTRO_OPENSUSE; + else if (VALUE_IS ("rhel")) + distro = OS_DISTRO_RHEL; + else if (VALUE_IS ("ubuntu")) + distro = OS_DISTRO_UBUNTU; + } else if (STRPREFIX (line, "PRETTY_NAME=")) { + free (product_name); + product_name = safe_strndup (g, value, value_len); + } else if (STRPREFIX (line, "VERSION_ID=")) { + char *major, *minor; + if (match2 (g, value, re_major_minor, &major, &minor)) { + major_version = guestfs_int_parse_unsigned_int (g, major); + free (major); + if (major_versi...
2016 Feb 06
1
[PATCH v3] inspect: get windows drive letters for GPT disks.
...disk and partition. */ - device = map_registry_disk_blob (g, blob); + if (is_gpt) + device = map_registry_disk_blob_gpt (g, blob); + else + device = map_registry_disk_blob (g, blob); + if (device != NULL) { fs->drive_mappings[count++] = safe_strndup (g, &key[12], 1); fs->drive_mappings[count++] = device; @@ -605,6 +615,88 @@ map_registry_disk_blob (guestfs_h *g, const void *blob) return safe_asprintf (g, "%s%d", devices[i], partitions->val[j].part_num); } +/* Matches Windows registry HKLM\SYSYTEM\MountedDev...
2016 Mar 29
0
[PATCH 1/2] added filesystem_walk API
...&len)) + return -1; + + buf = safe_malloc(g, len); + + if (!xdr_string(xdrs, &buf, len)) + return -1; + if (!xdr_uint64_t(xdrs, &node_info->tsk_inode)) + return -1; + if (!xdr_uint32_t(xdrs, &node_info->tsk_allocated)) + return -1; + + node_info->tsk_name = safe_strndup(g, buf, len); + + return 0; +} + +/* Free the nodes list. */ +static void +free_nodes(struct guestfs_tsk_node_list *nodes) +{ + uint32_t index = 0; + + for (index = 0; index < nodes->len; index++) + if (nodes->val[index].tsk_name != NULL) + free(nodes->val[index].tsk_name); +...
2016 Feb 05
7
[PATCH 0/7] lib: Stop exporting the safe_malloc, etc. functions.
The safe_malloc (etc) functions call g->abort_fn on failure. That's not appropriate for language bindings, and we never intended that these internal functions be used from language bindings, that was just a historical accident. This patch series removes any external use of the safe_* functions. Rich.
2016 Apr 03
0
[PATCH v2 4/5] appliance: Added filesystem_walk command
...gt;tsk_type)) + return -1; + if (!xdr_int64_t (xdrs, &dirent->tsk_size)) + return -1; + + /* Deserialise filename. */ + if (!xdr_u_long (xdrs, &len)) + return -1; + buf = safe_malloc (g, len); + if (!xdr_string (xdrs, &buf, len)) + return -1; + dirent->tsk_name = safe_strndup(g, buf, len); + + if (!xdr_uint32_t (xdrs, &dirent->tsk_allocated)) + return -1; + + return 0; +} -- 2.8.0.rc3
2010 Sep 20
1
[PATCH] Fix error launching libguestfs when euid != uid
...p) == -1) { - perror ("pclose"); + fclose (pp); + if (waitpid(pid, NULL, 0) == -1) { + perror ("waitpid"); return NULL; } @@ -197,6 +239,18 @@ calculate_supermin_checksum (guestfs_h *g, const char *supermin_path) checksum[--len] = '\0'; return safe_strndup (g, checksum, len); + + int dummy[128]; +helper_error: + /* Consume any remaining output, ignoring errors */ + while (read(fds[0], dummy, sizeof(dummy) > 0)) + ; + + if (waitpid(pid, NULL, 0) == -1) { + perror("reaping feboostrap-supermin-helper"); + } + + return NULL; }...
2016 Feb 05
1
Re: [PATCH] inspect: get windows drive letters for GPT disks.
...lob); > > +        if (is_gpt) > > +          device = map_registry_disk_blob_gpt (g, blob); > > +        else > > +          device = map_registry_disk_blob (g, blob); > > + > >          if (device != NULL) { > >            fs->drive_mappings[count++] = safe_strndup (g, &key[12], > > 1); > >            fs->drive_mappings[count++] = device; > > @@ -605,6 +614,91 @@ map_registry_disk_blob (guestfs_h *g, const > > void *blob) > >    return safe_asprintf (g, "%s%d", devices[i], partitions- > > >val[j].part_nu...
2018 Feb 12
0
[PATCH v2 1/1] Switch from YAJL to Jansson
...node)) - goto bad_type; - str = YAJL_GET_STRING (node); - if (str == NULL) - goto bad_type; - return safe_strdup (g, str); /* caller frees */ - } - } + node = json_object_get (tree, "format"); + if (!json_is_string (node)) + goto bad_type; + + return safe_strndup (g, json_string_value (node), + json_string_length (node)); /* caller frees */ bad_type: error (g, _("qemu-img info: JSON output did not contain ‘format’ key")); @@ -93,30 +86,20 @@ guestfs_impl_disk_format (guestfs_h *g, const char *filename) int64_t gue...