A couple of minor fixes to phyp escape_specialcharacters. Make it a static function (since it's only used in phyp/phyp_driver.c), and make it take a dstlen parameter. This paves the way for removing strncpy in the future. Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx> --- src/phyp/phyp_driver.c | 10 ++++++---- src/phyp/phyp_driver.h | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index cbfd31b..f457cf4 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -53,6 +53,8 @@ #define VIR_FROM_THIS VIR_FROM_PHYP +static int escape_specialcharacters(char *src, char *dst, size_t dstlen); + /* * URI: phyp://user@[hmc|ivm]/managed_system * */ @@ -94,7 +96,7 @@ phypOpen(virConnectPtr conn, return VIR_DRV_OPEN_ERROR; } - if (escape_specialcharacters(conn->uri->path, string) == -1) { + if (escape_specialcharacters(conn->uri->path, string, sizeof(string)) == -1) { virRaiseError(conn, NULL, NULL, 0, VIR_FROM_PHYP, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s", _("Error parsing 'path'. Invalid characters.")); @@ -1341,8 +1343,8 @@ init_uuid_db(virConnectPtr conn) return; } -int -escape_specialcharacters(char *src, char *dst) +static int +escape_specialcharacters(char *src, char *dst, size_t dstlen) { size_t len = strlen(src); char temp_buffer[len]; @@ -1367,7 +1369,7 @@ escape_specialcharacters(char *src, char *dst) } temp_buffer[j] = '\0'; - if (strncpy(dst, temp_buffer, j) == NULL) + if (strncpy(dst, temp_buffer, dstlen) == NULL) return -1; return 0; diff --git a/src/phyp/phyp_driver.h b/src/phyp/phyp_driver.h index fd824b3..f16b6fe 100644 --- a/src/phyp/phyp_driver.h +++ b/src/phyp/phyp_driver.h @@ -62,5 +62,3 @@ char *phypGetBackingDevice(virConnectPtr conn, const char *managed_system, int phypDiskType(virConnectPtr conn, char *backing_device); SSH_SESSION *openSSHSession(virConnectPtr conn, virConnectAuthPtr auth); - -int escape_specialcharacters(char *src, char *dst); -- 1.6.0.6 -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list