[ofa-general] [PATCH] osm: ignore line with invalid guid in guid2lid file
Sasha Khapyorsky
sashak at voltaire.com
Tue Apr 17 16:39:35 PDT 2007
On 17:43 Tue 17 Apr , Yevgeny Kliteynik wrote:
> Hi Hal,
>
> When parsing guid2lid file, invalid guid string
> ended up unpacked as guid 0x0. Ignoring line with
> invalid guid string.
>
> This bug doesn't look too important - don't think
> that it should go to ofed_1_2. Anyway, your call.
It looks like a safe change for me.
BTW any reason to use strtouq() instead of more popular (IMHO) strtoul()
or strtoull()?
Sasha
>
> -- Yevgeny
>
> Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
> ---
> osm/opensm/osm_db_files.c | 15 ++++++++++++---
> 1 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/osm/opensm/osm_db_files.c b/osm/opensm/osm_db_files.c
> index dbadd68..23eaa0b 100644
> --- a/osm/opensm/osm_db_files.c
> +++ b/osm/opensm/osm_db_files.c
> @@ -294,6 +294,7 @@ osm_db_restore(
> char *p_first_word, *p_rest_of_line, *p_last;
> char *p_key = NULL;
> char *p_prev_val, *p_accum_val = NULL;
> + char *endptr = NULL;
> unsigned int line_num;
>
> OSM_LOG_ENTER( p_log, osm_db_restore );
> @@ -415,12 +416,20 @@ osm_db_restore(
> p_prev_val = NULL;
> }
>
> - /* store our key and value */
> - st_insert(p_domain_imp->p_hash,
> - (st_data_t)p_key, (st_data_t)p_accum_val);
> osm_log( p_log, OSM_LOG_DEBUG,
> "osm_db_restore: "
> "Got key:%s value:%s\n", p_key, p_accum_val);
> +
> + /* check that the key is a number */
> + if (!strtouq(p_key,&endptr,0) && *endptr != '\0')
> + osm_log( p_log, OSM_LOG_ERROR,
> + "osm_db_restore: ERR 610B: "
> + "Key:%s is invalid\n",
> + p_key);
> + else
> + /* store our key and value */
> + st_insert(p_domain_imp->p_hash,
> + (st_data_t)p_key, (st_data_t)p_accum_val);
> }
> else
> {
> --
> 1.4.4.1.GIT
>
>
> _______________________________________________
> general mailing list
> general at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general
>
> To unsubscribe, please visit
> http://openib.org/mailman/listinfo/openib-general
More information about the general
mailing list