File tree 4 files changed +20
-21
lines changed
4 files changed +20
-21
lines changed Original file line number Diff line number Diff line change 2
2
3
3
* dmidecode.c: Fix up invalid DMI type 34 structure length.
4
4
* dmioem.c: Decode HP-specific DMI types 212 and 219.
5
+ * dmioem.c: Move function is_printable to dmidecode.c.
5
6
6
7
2015-05-13 Jean Delvare <
[email protected] >
7
8
Original file line number Diff line number Diff line change @@ -81,6 +81,18 @@ static const char *bad_index = "<BAD INDEX>";
81
81
* Type-independant Stuff
82
82
*/
83
83
84
+ /* Returns 1 if the buffer contains only printable ASCII characters */
85
+ int is_printable (const u8 * data , int len )
86
+ {
87
+ int i ;
88
+
89
+ for (i = 0 ; i < len ; i ++ )
90
+ if (data [i ] < 32 || data [i ] >= 127 )
91
+ return 0 ;
92
+
93
+ return 1 ;
94
+ }
95
+
84
96
const char * dmi_string (const struct dmi_header * dm , u8 s )
85
97
{
86
98
char * bp = (char * )dm -> data ;
@@ -2937,18 +2949,14 @@ static void dmi_64bit_memory_error_address(u64 code)
2937
2949
static void dmi_fixup_type_34 (struct dmi_header * h )
2938
2950
{
2939
2951
u8 * p = h -> data ;
2940
- int i ;
2941
-
2942
- if (h -> length != 0x10 )
2943
- return ;
2944
2952
2945
2953
/* Make sure the hidden data is ASCII only */
2946
- for ( i = 0x0B ; i < 0x10 ; i ++ )
2947
- if ( p [ i ] < 32 || p [ i ] >= 127 )
2948
- return ;
2949
-
2950
- printf ( "Invalid entry length (%u). Fixed up to %u.\n" , 0x10 , 0x0B ) ;
2951
- h -> length = 0x0B ;
2954
+ if ( h -> length == 0x10
2955
+ && is_printable ( p + 0x0B , 0x10 - 0x0B ) )
2956
+ {
2957
+ printf ( "Invalid entry length (%u). Fixed up to %u.\n" , 0x10 , 0x0B );
2958
+ h -> length = 0x0B ;
2959
+ }
2952
2960
}
2953
2961
2954
2962
static const char * dmi_management_device_type (u8 code )
Original file line number Diff line number Diff line change @@ -28,4 +28,5 @@ struct dmi_header
28
28
u8 * data ;
29
29
};
30
30
31
+ int is_printable (const u8 * data , int len );
31
32
const char * dmi_string (const struct dmi_header * dm , u8 s );
Original file line number Diff line number Diff line change @@ -62,17 +62,6 @@ void dmi_set_vendor(const char *s)
62
62
dmi_vendor = VENDOR_ACER ;
63
63
}
64
64
65
- static int is_printable (const u8 * data , int len )
66
- {
67
- int i ;
68
-
69
- for (i = 0 ; i < len ; i ++ )
70
- if (data [i ] < 32 || data [i ] >= 127 )
71
- return 0 ;
72
-
73
- return 1 ;
74
- }
75
-
76
65
/*
77
66
* HP-specific data structures are decoded here.
78
67
*
You can’t perform that action at this time.
0 commit comments