[libvirt] [PATCHv2 3/5] Strip control characters from sysfs attributes

Peter Krempa pkrempa at redhat.com
Wed Apr 15 12:37:21 UTC 2015


On Tue, Apr 14, 2015 at 13:28:48 +0200, Ján Tomko wrote:
> Including them in the XML makes them unparsable.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1184131
> ---
>  src/node_device/node_device_udev.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
> index 8c39e5f..5e98222 100644
> --- a/src/node_device/node_device_udev.c
> +++ b/src/node_device/node_device_udev.c
> @@ -239,6 +239,8 @@ static int udevGetStringSysfsAttr(struct udev_device *udev_device,
>  
>      ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &tmp);
>  
> +    virStringStripControlChars(tmp);
> +

Looks safe enoguh to me, but I'd state in a comment that this function
strips possible control chars.

>      if (tmp != NULL && (STREQ(tmp, ""))) {
>          VIR_FREE(tmp);
>          tmp = NULL;

ACK with comment added.

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150415/3452faa5/attachment-0001.sig>


More information about the libvir-list mailing list