Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the nvt preference is "file" type, encode it into Base64 format. #784

Merged
merged 3 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix array index error when modifying roles and groups [#762](https://github.com/greenbone/gvmd/pull/762)
- Make get_settings return only one setting when setting_id is given [#780](https://github.com/greenbone/gvmd/pull/780)
- Fix percent sign escaping in report_port_count [#783](https://github.com/greenbone/gvmd/pull/783)
- If the nvt preference is "file" type, encode it into Base64 format [#784](https://github.com/greenbone/gvmd/pull/784)

### Removed
- The handling of NVT updates via OTP has been removed. [#575](https://github.com/greenbone/gvmd/pull/575)
Expand Down
5 changes: 4 additions & 1 deletion src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -3787,7 +3787,8 @@ target_osp_ssh_credential (target_t target)
const char *private_key = credential_iterator_private_key (&iter);
osp_credential_set_auth_data (osp_credential,
"private",
private_key);
g_base64_encode ((guchar *) private_key,
strlen(private_key)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
strlen(private_key)));
strlen (private_key)));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the memory of private_key was managed as part of iter, but g_base64_encode
allocates new memory, so isn't this a leak?

}
cleanup_iterator (&iter);
return osp_credential;
Expand Down Expand Up @@ -4091,6 +4092,8 @@ launch_osp_openvas_task (task_t task, target_t target, const char *scan_id,
osp_value = g_strdup (split_value[0]);
g_strfreev (split_value);
}
else if (strcmp (type, "file") == 0)
osp_value = g_base64_encode ((guchar*) value, strlen(value));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
osp_value = g_base64_encode ((guchar*) value, strlen(value));
osp_value = g_base64_encode ((guchar*) value, strlen (value));


osp_vt = g_hash_table_lookup (vts_hash_table, oid);
if (osp_vt)
Expand Down