From b64aa0ef375f2df3ce166733fe92429ba43b6145 Mon Sep 17 00:00:00 2001 From: Matthieu Herrb Date: Tue, 20 Oct 2015 14:48:52 -0400 Subject: Get rid of strcpy() in the HAVE_UUID_CREATE case Even though this use was safe, some linkers produce a warning when strcpy() is used, and this is the only use in libSM. Reviewed-by: Alan Coopersmith --- src/sm_genid.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/sm_genid.c b/src/sm_genid.c index 2500fcf..1a8b9a0 100644 --- a/src/sm_genid.c +++ b/src/sm_genid.c @@ -111,16 +111,15 @@ SmsGenerateClientID(SmsConn smsConn) char *temp; uuid_t uuid; uint32_t status; + size_t len; uuid_create(&uuid, &status); uuid_to_string(&uuid, &temp, &status); - if ((id = malloc (strlen (temp) + 2)) != NULL) - { - id[0] = '2'; - strcpy (id+1, temp); - } + len = strlen(temp) + 2; + if ((id = malloc(len)) != NULL) + snprintf(id, len, "2%s", temp); free(temp); -- cgit v1.2.3