Skip to content

Commit fe6f97b

Browse files
committed
fix: define a constant buffer_size = 1024 and reuse it in setting updateinformation max size
1 parent ee24c2b commit fe6f97b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/appimagetool.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,10 @@ main (int argc, char *argv[])
825825
* should hopefully change that. */
826826

827827
fprintf (stderr, "Generating squashfs...\n");
828+
const int buffer_size = 1024;
828829
int size = 0;
830+
831+
829832
char* data = NULL;
830833
bool using_external_data = false;
831834
if (runtime_file != NULL) {
@@ -866,10 +869,11 @@ main (int argc, char *argv[])
866869
printf("Could not set executable bit, aborting\n");
867870
exit(1);
868871
}
869-
872+
873+
870874
if(bintray_user != NULL){
871875
if(bintray_repo != NULL){
872-
char buf[1024];
876+
char buf[buffer_size];
873877
sprintf(buf, "bintray-zsync|%s|%s|%s|%s-_latestVersion-%s.AppImage.zsync", bintray_user, bintray_repo, app_name_for_filename, app_name_for_filename, arch);
874878
updateinformation = buf;
875879
printf("%s\n", updateinformation);
@@ -924,7 +928,7 @@ main (int argc, char *argv[])
924928
} else {
925929
channel = "continuous";
926930
}
927-
int is_zsync_write_success = snprintf(buf, 1024, "gh-releases-zsync|%s|%s|%s|%s*-%s.AppImage.zsync", parts[0], parts[1], channel, app_name_for_filename, arch);
931+
int is_zsync_write_success = snprintf(buf, buffer_size, "gh-releases-zsync|%s|%s|%s|%s*-%s.AppImage.zsync", parts[0], parts[1], channel, app_name_for_filename, arch);
928932
if (is_zsync_write_success < 0) {
929933
printf("Writing updateinformation failed. zsync information is too long. (> 1024)\n");
930934
exit(is_zsync_write_success);

0 commit comments

Comments
 (0)