diff options
author | Vladimir Kobal <vlad@prokk.net> | 2019-05-14 18:35:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-14 18:35:12 +0300 |
commit | 0d5fa83e224afa6d530ed6a5e6e6fe35a8af955e (patch) | |
tree | 99a1a33870b26e93b18693dc2775888abcd298b6 /database/rrdhost.c | |
parent | 1833691018fda9eb6b80eed373c482a394a1267e (diff) |
Fix segmentation fault (#6011)
* Fix segmentation fault
* Make system info printing safe
* Fix quotes for OS name
Diffstat (limited to 'database/rrdhost.c')
-rw-r--r-- | database/rrdhost.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/database/rrdhost.c b/database/rrdhost.c index de0366267c..3b06ed1ada 100644 --- a/database/rrdhost.c +++ b/database/rrdhost.c @@ -825,19 +825,32 @@ struct rrdhost_system_info *rrdhost_system_info_dup(struct rrdhost_system_info * struct rrdhost_system_info *ret = callocz(1, sizeof(struct rrdhost_system_info)); if(likely(system_info)) { - ret->os_name = strdupz(system_info->os_name); - ret->os_id = strdupz(system_info->os_id); - ret->os_id_like = strdupz(system_info->os_id_like); - ret->os_version = strdupz(system_info->os_version); - ret->os_version_id = strdupz(system_info->os_version_id); - ret->os_detection = strdupz(system_info->os_detection); - ret->kernel_name = strdupz(system_info->kernel_name); - ret->kernel_version = strdupz(system_info->kernel_version); - ret->architecture = strdupz(system_info->architecture); - ret->virtualization = strdupz(system_info->virtualization); - ret->virt_detection = strdupz(system_info->virt_detection); - ret->container = strdupz(system_info->container); - ret->container_detection = strdupz(system_info->container_detection); + if(system_info->os_name) + ret->os_name = strdupz(system_info->os_name); + if(system_info->os_id) + ret->os_id = strdupz(system_info->os_id); + if(system_info->os_id_like) + ret->os_id_like = strdupz(system_info->os_id_like); + if(system_info->os_version) + ret->os_version = strdupz(system_info->os_version); + if(system_info->os_version_id) + ret->os_version_id = strdupz(system_info->os_version_id); + if(system_info->os_detection) + ret->os_detection = strdupz(system_info->os_detection); + if(system_info->kernel_name) + ret->kernel_name = strdupz(system_info->kernel_name); + if(system_info->kernel_version) + ret->kernel_version = strdupz(system_info->kernel_version); + if(system_info->architecture) + ret->architecture = strdupz(system_info->architecture); + if(system_info->virtualization) + ret->virtualization = strdupz(system_info->virtualization); + if(system_info->virt_detection) + ret->virt_detection = strdupz(system_info->virt_detection); + if(system_info->container) + ret->container = strdupz(system_info->container); + if(system_info->container_detection) + ret->container_detection = strdupz(system_info->container_detection); } return ret; |