[PATCH phosphor-host-ipmid v2] Add Get Device UUID
Patrick Williams
patrick at stwcx.xyz
Wed Oct 28 05:41:21 AEDT 2015
On Fri, Oct 23, 2015 at 05:25:14PM -0500, OpenBMC Patches wrote:
> From: Adriana Kobylak <anoo at us.ibm.com>
>
> Add support to get the UUID and return it in the specified
> format per the IPMI Spec 2.0
> ---
> apphandler.C | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> apphandler.h | 1 +
> ipmid-api.h | 7 +++--
> 3 files changed, 95 insertions(+), 3 deletions(-)
>
> diff --git a/apphandler.C b/apphandler.C
> index 40cd79d..53c7ac2 100755
> --- a/apphandler.C
> +++ b/apphandler.C
> +
> + // Traverse the UUID
> + char* id_octet = strtok(uuid, "-"); // Get the UUID octects separated by dash
strtok shouldn't be used because it is not thread-safe. Use strtok_r.
> + for(i = 0; i < tmp_size; i++)
> + {
> + char tmp_array[3]; // Holder of the 2 chars that will become a byte
Need to initialize this to ensure the last byte is the null terminator.
Otherwise, strtoul will cause a buffer overrun.
> + strncpy(tmp_array, id_octet, 2); // 2 chars at a time
> +
> + int resp_byte = strtoul(tmp_array, NULL, 16); // Convert to hex byte
...
> + id_octet=strtok(NULL, "-"); // Get next octet
Another strtok.
--
Patrick Williams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20151027/a9cc4bf5/attachment-0001.sig>
More information about the openbmc
mailing list