@@ -37,17 +37,33 @@ static bool read_boot_entry(uint16_t number, bythos_efi_boot_entry_t *entry) {
3737static size_t check_efivars_boot (check_result_t * results , size_t max_results ) {
3838 size_t used = 0 ;
3939
40+ if (!bythos_file_exists ("/sys/firmware/efi/efivars" )) {
41+ EMIT_SKIP_FEATURE ("EFI USB boot" , "EFI runtime" );
42+ EMIT_SKIP_FEATURE ("EFI network boot" , "EFI runtime" );
43+ EMIT_SKIP_FEATURE ("EFI CD/DVD boot" , "EFI runtime" );
44+ EMIT_SKIP_FEATURE ("EFI one-shot boot" , "EFI runtime" );
45+ return used ;
46+ }
47+
4048 unsigned char order_buf [256 ];
4149 size_t order_len = 0 ;
4250
4351 if (!bythos_read_file_binary (EFI_BOOT_ORDER_PATH , order_buf ,
4452 sizeof (order_buf ), & order_len )) {
45- return 0 ;
53+ EMIT_SKIP_FEATURE ("EFI USB boot" , "BootOrder variable" );
54+ EMIT_SKIP_FEATURE ("EFI network boot" , "BootOrder variable" );
55+ EMIT_SKIP_FEATURE ("EFI CD/DVD boot" , "BootOrder variable" );
56+ EMIT_SKIP_FEATURE ("EFI one-shot boot" , "BootOrder variable" );
57+ return used ;
4658 }
4759
4860 bythos_efi_boot_order_t order = {0 };
4961 if (!bythos_parse_efi_boot_order (order_buf , order_len , & order )) {
50- return 0 ;
62+ EMIT_SKIP ("EFI USB boot" , SKIP_OUTPUT_UNPARSEABLE , "BootOrder variable malformed" );
63+ EMIT_SKIP ("EFI network boot" , SKIP_OUTPUT_UNPARSEABLE , "BootOrder variable malformed" );
64+ EMIT_SKIP ("EFI CD/DVD boot" , SKIP_OUTPUT_UNPARSEABLE , "BootOrder variable malformed" );
65+ EMIT_SKIP ("EFI one-shot boot" , SKIP_OUTPUT_UNPARSEABLE , "BootOrder variable malformed" );
66+ return used ;
5167 }
5268
5369 /* Only active risky entries are a real posture signal. */
@@ -154,7 +170,7 @@ static size_t check_firmware_attrs_boot(check_result_t *results, size_t max_resu
154170 char value [64 ] = {0 };
155171 struct dirent * vendor ;
156172
157- while ((vendor = readdir (vendors )) != NULL ) {
173+ while ((vendor = bythos_readdir_safe (vendors , NULL )) != NULL ) {
158174 if (vendor -> d_name [0 ] == '.' ) {
159175 continue ;
160176 }
@@ -170,7 +186,7 @@ static size_t check_firmware_attrs_boot(check_result_t *results, size_t max_resu
170186 }
171187
172188 struct dirent * attr ;
173- while ((attr = readdir (attrs )) != NULL ) {
189+ while ((attr = bythos_readdir_safe (attrs , NULL )) != NULL ) {
174190 if (attr -> d_name [0 ] == '.' ) {
175191 continue ;
176192 }
@@ -281,6 +297,10 @@ static size_t check_firmware_password(check_result_t *results, size_t max_result
281297 while (* pos == ' ' || * pos == '\t' ) {
282298 pos ++ ;
283299 }
300+ if ((size_t )((buf + sizeof (buf )) - pos ) < 9 ) {
301+ EMIT_SKIP_PARSE (slots [i ].name , "dmidecode" );
302+ continue ;
303+ }
284304 char term = pos [7 ];
285305 if (strncmp (pos , "Enabled" , 7 ) == 0 &&
286306 (term == '\0' || term == '\n' || term == '\r' || term == ' ' || term == '\t' )) {
0 commit comments