[ofa-general] [PATCH] osm: ignore line with invalid guid in guid2lid file

Hal Rosenstock halr at voltaire.com
Tue Apr 24 08:36:56 PDT 2007


On Wed, 2007-04-18 at 02:05, Yevgeny Kliteynik wrote:
> Sasha Khapyorsky wrote:
> > 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()?
> 
> No particular reason.
> It specifically says that the function "convert string to an unsigned 
> 64-bit integer" instead of unsigned long or unsigned long long, but
> on the other hand it doesn't matter, because uint64_t is a typedef anyway.
> If you have special sentiments about strtoul/strtoull - feel free to change it.

Is strtouq supported in Windows ?

-- Hal

> -- Yevgeny
> 
> 
> > 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