summaryrefslogtreecommitdiff
path: root/src/sm_genid.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@herrb.eu>2015-10-20 14:48:52 -0400
committerAdam Jackson <ajax@redhat.com>2015-10-20 14:50:53 -0400
commitb64aa0ef375f2df3ce166733fe92429ba43b6145 (patch)
tree858c9a71f946ca14baf06b60ddbc864f6b76eb42 /src/sm_genid.c
parent0bf5d26d1d55029846514758f2ffd80e816bd9fb (diff)
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 <alan.coopersmith@oracle.com>
Diffstat (limited to 'src/sm_genid.c')
-rw-r--r--src/sm_genid.c9
1 files 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);