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

Re: [PATCH 1/7] Mini-OS: xenbus: add support for reading node from directory



Hello,

Juergen Gross, le ven. 03 févr. 2023 10:18:03 +0100, a ecrit:
> +char *xenbus_read_unsigned(xenbus_transaction_t xbt, const char *dir,
> +                           const char *node, unsigned int *value)
> +{
> +    char path[BUFFER_SIZE];
> +    char *msg;
> +    char *str;
> +
> +    xenbus_build_path(dir, node, path);
> +    msg = xenbus_read(xbt, path, &str);
> +    if ( msg )
> +        return msg;
> +
> +    sscanf(str, "%u", value);

I'd say better check that sscanf returned 1 and otherwise return an
error. Otherwise *value may end up uninitialized.

> +    free(str);
> +
> +    return NULL;
> +}



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.