(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/uat.c) |
| |
| 628 | | | } else { |
| 629 | | | g_snprintf(s,5,"\\x%.2x",((guint)*b)); |
| 630 | | | s+=4; |
| 631 | | | } |
| 632 | | | } |
| 633 | | | |
| 634 | | | return out; |
| 635 | | | |
| 636 | | | } |
| 637 | | | |
| 638 | | | CHK_STR_IS_DEF(isprint)
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/uat.h |
| |
305 | #define CHK_STR_IS_DEF(what) \ |
306 | gboolean uat_fld_chk_str_ ## what (void* u1 _U_, const char* strptr, unsigned len, const void* u2 _U_, const void* u3 _U_, const char** err) { \ |
307 | guint i; for (i=0;i<len;i++) { \ |
308 | char c = strptr[i]; \ |
309 | if (! what((int)c)) { \ |
310 | *err = ep_strdup_printf("invalid char pos=%d value=%.2x",i,c); return FALSE; } } \ |
311 | *err = NULL; return TRUE; } |
| |
|
Negative Character Value
isprint() is invoked here with an argument of signed type char, but only has defined behavior for int arguments that are either representable as unsigned char or equal to the value of macro EOF (-1). - Casting the argument to unsigned char will avoid the undefined behavior.
In a number of libc implementations isprint() is implemented using lookup tables (arrays): passing in a negative value can result in a read underrun. |
|
| 639 | | | CHK_STR_IS_DEF(isalpha)
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/uat.h |
| |
305 | #define CHK_STR_IS_DEF(what) \ |
306 | gboolean uat_fld_chk_str_ ## what (void* u1 _U_, const char* strptr, unsigned len, const void* u2 _U_, const void* u3 _U_, const char** err) { \ |
307 | guint i; for (i=0;i<len;i++) { \ |
308 | char c = strptr[i]; \ |
309 | if (! what((int)c)) { \ |
310 | *err = ep_strdup_printf("invalid char pos=%d value=%.2x",i,c); return FALSE; } } \ |
311 | *err = NULL; return TRUE; } |
| |
|
| 640 | | | CHK_STR_IS_DEF(isalnum)
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/uat.h |
| |
305 | #define CHK_STR_IS_DEF(what) \ |
306 | gboolean uat_fld_chk_str_ ## what (void* u1 _U_, const char* strptr, unsigned len, const void* u2 _U_, const void* u3 _U_, const char** err) { \ |
307 | guint i; for (i=0;i<len;i++) { \ |
308 | char c = strptr[i]; \ |
309 | if (! what((int)c)) { \ |
310 | *err = ep_strdup_printf("invalid char pos=%d value=%.2x",i,c); return FALSE; } } \ |
311 | *err = NULL; return TRUE; } |
| |
|
| 641 | | | CHK_STR_IS_DEF(isdigit)
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/uat.h |
| |
305 | #define CHK_STR_IS_DEF(what) \ |
306 | gboolean uat_fld_chk_str_ ## what (void* u1 _U_, const char* strptr, unsigned len, const void* u2 _U_, const void* u3 _U_, const char** err) { \ |
307 | guint i; for (i=0;i<len;i++) { \ |
308 | char c = strptr[i]; \ |
309 | if (! what((int)c)) { \ |
310 | *err = ep_strdup_printf("invalid char pos=%d value=%.2x",i,c); return FALSE; } } \ |
311 | *err = NULL; return TRUE; } |
| |
|
| 642 | | | CHK_STR_IS_DEF(isxdigit)
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/uat.h |
| |
305 | #define CHK_STR_IS_DEF(what) \ |
306 | gboolean uat_fld_chk_str_ ## what (void* u1 _U_, const char* strptr, unsigned len, const void* u2 _U_, const void* u3 _U_, const char** err) { \ |
307 | guint i; for (i=0;i<len;i++) { \ |
308 | char c = strptr[i]; \ |
309 | if (! what((int)c)) { \ |
310 | *err = ep_strdup_printf("invalid char pos=%d value=%.2x",i,c); return FALSE; } } \ |
311 | *err = NULL; return TRUE; } |
| |
|
| 643 | | | |
| 644 | | | |
| 645 | | | |
| 646 | | | |
| 647 | | | |
| 648 | | | |
| |