Re: [PATCH v2 01/11] monitor: Detect string format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Thu, Dec 14, 2017 at 10:02 AM, Luiz Augusto von Dentz
<luiz.dentz@xxxxxxxxx> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>
>
> User may enter UUID in string format other then 128 bits.
> ---
>  monitor/uuid.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/monitor/uuid.c b/monitor/uuid.c
> index 9839d03be..bc638a2f3 100644
> --- a/monitor/uuid.c
> +++ b/monitor/uuid.c
> @@ -27,6 +27,7 @@
>  #endif
>
>  #include <stdio.h>
> +#include <stdlib.h>
>  #include <string.h>
>
>  #include "uuid.h"
> @@ -735,12 +736,28 @@ const char *uuid32_to_str(uint32_t uuid)
>  const char *uuidstr_to_str(const char *uuid)
>  {
>         uint32_t val;
> +       size_t len;
>         int i;
>
>         if (!uuid)
>                 return NULL;
>
> -       if (strlen(uuid) != 36)
> +       len = strlen(uuid);
> +
> +       if (len < 36) {
> +               char *endptr = NULL;
> +
> +               val = strtol(uuid, &endptr, 0);
> +               if (!endptr || *endptr != '\0')
> +                       return NULL;
> +
> +               if (val > UINT16_MAX)
> +                       return uuid32_to_str(val);
> +
> +               return uuid16_to_str(val);
> +       }
> +
> +       if (len != 36)
>                 return NULL;
>
>         for (i = 0; uuid128_table[i].str; i++) {
> --
> 2.13.6

Patches 1-9 have been applied.


-- 
Luiz Augusto von Dentz
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux