@@ -58,7 +58,9 @@ verify_crc32sums(const char *pkg_dir, const char *sums_path)
5858 char hash_str [9 ] = {0 };
5959 char rel_path [PATH_MAX ];
6060
61- if (sscanf (line , "%8s %4095s" , hash_str , rel_path ) != 2 )
61+ char fmt [32 ];
62+ snprintf (fmt , sizeof (fmt ), "%%8s %%%zus" , sizeof (rel_path ) - 1 );
63+ if (sscanf (line , fmt , hash_str , rel_path ) != 2 )
6264 continue ;
6365
6466 char * full_path = concat_dirs (pkg_dir , rel_path );
@@ -99,7 +101,9 @@ verify_md5sums(const char *pkg_dir, const char *sums_path)
99101 char hash_str [33 ] = {0 };
100102 char rel_path [PATH_MAX ];
101103
102- if (sscanf (line , "%32s %4095s" , hash_str , rel_path ) != 2 )
104+ char fmt [32 ];
105+ snprintf (fmt , sizeof (fmt ), "%%32s %%%zus" , sizeof (rel_path ) - 1 );
106+ if (sscanf (line , fmt , hash_str , rel_path ) != 2 )
103107 continue ;
104108
105109 char * full_path = concat_dirs (pkg_dir , rel_path );
@@ -148,7 +152,9 @@ verify_sha256sums(const char *pkg_dir, const char *sums_path)
148152 char hash_str [65 ] = {0 };
149153 char rel_path [PATH_MAX ];
150154
151- if (sscanf (line , "%64s %4095s" , hash_str , rel_path ) != 2 )
155+ char fmt [32 ];
156+ snprintf (fmt , sizeof (fmt ), "%%64s %%%zus" , sizeof (rel_path ) - 1 );
157+ if (sscanf (line , fmt , hash_str , rel_path ) != 2 )
152158 continue ;
153159
154160 char * full_path = concat_dirs (pkg_dir , rel_path );
0 commit comments