File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -593,6 +593,7 @@ static bool _system_is_in_bootc_mode(void)
593593 return false;
594594#else
595595 #define BOOTC_PATH "/usr/bin/bootc"
596+ #define CHUNK_SIZE 1024
596597 struct stat statbuf ;
597598 if (stat (BOOTC_PATH , & statbuf ) == -1 ) {
598599 return false;
@@ -601,12 +602,21 @@ static bool _system_is_in_bootc_mode(void)
601602 if (output == NULL ) {
602603 return false;
603604 }
604- char buf [1024 ] = {0 };
605+ size_t buf_size = CHUNK_SIZE ;
606+ char * buf = calloc (buf_size , sizeof (char ));
605607 int c ;
606608 size_t i = 0 ;
607- while (i < sizeof (buf ) && (c = fgetc (output )) != EOF ) {
608- buf [i ] = c ;
609- i ++ ;
609+ while ((c = fgetc (output )) != EOF ) {
610+ if (i >= buf_size ) {
611+ buf_size += CHUNK_SIZE ;
612+ char * new_buf = realloc (buf , buf_size );
613+ if (new_buf == NULL ) {
614+ pclose (output );
615+ return false;
616+ }
617+ buf = new_buf ;
618+ }
619+ buf [i ++ ] = c ;
610620 }
611621 pclose (output );
612622 return * buf != '\0' && strstr (buf , "\"booted\":null" ) == NULL ;
You can’t perform that action at this time.
0 commit comments