tree-walk: learn get_tree_entry_follow_symlinks
[gitweb.git] / send-pack.c
index 9d2b0c52ed8235425795772db99fc14ea9c2bf2b..2a64fec949ea9495b5b9512399cec7979319de1c 100644 (file)
@@ -182,7 +182,7 @@ static int advertise_shallow_grafts_cb(const struct commit_graft *graft, void *c
 {
        struct strbuf *sb = cb;
        if (graft->nr_parent == -1)
-               packet_buf_write(sb, "shallow %s\n", sha1_to_hex(graft->sha1));
+               packet_buf_write(sb, "shallow %s\n", oid_to_hex(&graft->oid));
        return 0;
 }
 
@@ -308,6 +308,28 @@ static int atomic_push_failure(struct send_pack_args *args,
                     failing_ref->name, failing_ref->status);
 }
 
+#define NONCE_LEN_LIMIT 256
+
+static void reject_invalid_nonce(const char *nonce, int len)
+{
+       int i = 0;
+
+       if (NONCE_LEN_LIMIT <= len)
+               die("the receiving end asked to sign an invalid nonce <%.*s>",
+                   len, nonce);
+
+       for (i = 0; i < len; i++) {
+               int ch = nonce[i] & 0xFF;
+               if (isalnum(ch) ||
+                   ch == '-' || ch == '.' ||
+                   ch == '/' || ch == '+' ||
+                   ch == '=' || ch == '_')
+                       continue;
+               die("the receiving end asked to sign an invalid nonce <%.*s>",
+                   len, nonce);
+       }
+}
+
 int send_pack(struct send_pack_args *args,
              int fd[], struct child_process *conn,
              struct ref *remote_refs,
@@ -354,6 +376,7 @@ int send_pack(struct send_pack_args *args,
                push_cert_nonce = server_feature_value("push-cert", &len);
                if (!push_cert_nonce)
                        die(_("the receiving end does not support --signed push"));
+               reject_invalid_nonce(push_cert_nonce, len);
                push_cert_nonce = xmemdupz(push_cert_nonce, len);
        }
 
@@ -363,7 +386,7 @@ int send_pack(struct send_pack_args *args,
                return 0;
        }
        if (args->atomic && !atomic_supported)
-               die(_("server does not support --atomic push"));
+               die(_("the receiving end does not support --atomic push"));
 
        use_atomic = atomic_supported && args->atomic;