commit 110104b65c5b511d6e99058e536c132ab962d863 from: Stefan Sperling date: Mon Nov 07 16:05:02 2022 UTC fix crash in got-send-pack when server does not announce any capabilities commit - 758dc042e8fc2399dc58d96ce6d80b4a0adf4705 commit + 110104b65c5b511d6e99058e536c132ab962d863 blob - 0e18f194406f1c8fe2f30bab9b5c8a3a3c0a6e5f blob + e4d0f25b9ed093ef2eedaffd7a65b3d05e786a3e --- libexec/got-send-pack/got-send-pack.c +++ libexec/got-send-pack/got-send-pack.c @@ -353,6 +353,13 @@ send_pack(int fd, struct got_pathlist_head *refs, if (err) goto done; if (is_firstpkt) { + if (server_capabilities == NULL) { + server_capabilities = strdup(""); + if (server_capabilities == NULL) { + err = got_error_from_errno("strdup"); + goto done; + } + } if (chattygot && server_capabilities[0] != '\0') fprintf(stderr, "%s: server capabilities: %s\n", getprogname(), server_capabilities); @@ -363,7 +370,8 @@ send_pack(int fd, struct got_pathlist_head *refs, goto done; if (chattygot) fprintf(stderr, "%s: my capabilities:%s\n", - getprogname(), my_capabilities); + getprogname(), + my_capabilities ? my_capabilities : ""); is_firstpkt = 0; } if (strstr(refname, "^{}")) {