diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2009-03-08 22:36:43 +0000 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2009-03-08 22:36:43 +0000 |
commit | 7870c69a9179ca0e3faf3c5dabe54c1511d5608c (patch) | |
tree | 7967a730702de686fc44b4dc97ca501bbe09bbf0 /epan/uat.c | |
parent | b4c2f2044ad336e47c789a57da55d2f46ce681ee (diff) |
Handle a empty string as "0" when checking numeric uat values, because
strtol() will set errno on some platforms and not on other platforms.
With this change we don't need to set a value in DLT_USER header size
and trailer size.
Also remove an unused strdup.
svn path=/trunk/; revision=27664
Diffstat (limited to 'epan/uat.c')
-rw-r--r-- | epan/uat.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/epan/uat.c b/epan/uat.c index 5f2016cbf1..6b8e7ae58e 100644 --- a/epan/uat.c +++ b/epan/uat.c @@ -265,6 +265,7 @@ gboolean uat_save(uat_t* uat, char** error) { } *error = NULL; + g_free (fname); fprintf(fp,"# This file is automatically generated, DO NOT MODIFY.\n"); @@ -415,26 +416,30 @@ gboolean uat_fld_chk_proto(void* u1 _U_, const char* strptr, unsigned len, void* } gboolean uat_fld_chk_num_dec(void* u1 _U_, const char* strptr, unsigned len, void* u2 _U_, void* u3 _U_, const char** err) { - char* str = ep_strndup(strptr,len); - long i = strtol(str,&str,10); + if (len > 0) { + char* str = ep_strndup(strptr,len); + long i = strtol(str,&str,10); - if ( ( i == 0) && (errno == ERANGE || errno == EINVAL) ) { - *err = strerror(errno); - return FALSE; - } + if ( ( i == 0) && (errno == ERANGE || errno == EINVAL) ) { + *err = strerror(errno); + return FALSE; + } + } *err = NULL; return TRUE; } gboolean uat_fld_chk_num_hex(void* u1 _U_, const char* strptr, unsigned len, void* u2 _U_, void* u3 _U_, const char** err) { - char* str = ep_strndup(strptr,len); - long i = strtol(str,&str,16); + if (len > 0) { + char* str = ep_strndup(strptr,len); + long i = strtol(str,&str,16); - if ( ( i == 0) && (errno == ERANGE || errno == EINVAL) ) { - *err = strerror(errno); - return FALSE; - } + if ( ( i == 0) && (errno == ERANGE || errno == EINVAL) ) { + *err = strerror(errno); + return FALSE; + } + } *err = NULL; return TRUE; |