--- auth-options.c	Mon Mar 20 03:39:27 2017
+++ auth-options.c	Mon Jul 31 00:40:02 2017
@@ -480,8 +480,8 @@
 			    ssh_err(r));
 			goto out;
 		}
-		debug3("found certificate option \"%.100s\" len %zu",
-		    name, sshbuf_len(data));
+		debug3("found certificate option \"%.100s\" len %lu",
+		    name, (unsigned long) sshbuf_len(data));
 		found = 0;
 		if ((which & OPTIONS_EXTENSIONS) != 0) {
 			if (strcmp(name, "permit-X11-forwarding") == 0) {
--- auth-pam.c	Mon Mar 20 03:39:27 2017
+++ auth-pam.c	Mon Jul 31 00:40:02 2017
@@ -827,7 +827,7 @@
 	size_t i, l = wire_password != NULL ? strlen(wire_password) : 0;
 
 	if (l >= INT_MAX)
-		fatal("%s: password length too long: %zu", __func__, l);
+		fatal("%s: password length too long: %lu", __func__, (unsigned long) l);
 
 	ret = malloc(l + 1);
 	if (ret == NULL)
--- clientloop.c	Mon Mar 20 03:39:27 2017
+++ clientloop.c	Mon Jul 31 00:40:01 2017
@@ -2244,8 +2244,8 @@
 	    sshkey_ssh_name(l->key), l->path, l->linenum);
 	if ((tmp = reallocarray(ctx->old_keys, ctx->nold + 1,
 	    sizeof(*ctx->old_keys))) == NULL)
-		fatal("%s: reallocarray failed nold = %zu",
-		    __func__, ctx->nold);
+		fatal("%s: reallocarray failed nold = %lu",
+		    __func__, (unsigned long) ctx->nold);
 	ctx->old_keys = tmp;
 	ctx->old_keys[ctx->nold++] = l->key;
 	l->key = NULL;
@@ -2371,8 +2371,8 @@
 		}
 		if ((r = sshkey_verify(ctx->keys[i], sig, siglen,
 		    sshbuf_ptr(signdata), sshbuf_len(signdata), 0)) != 0) {
-			error("%s: server gave bad signature for %s key %zu",
-			    __func__, sshkey_type(ctx->keys[i]), i);
+			error("%s: server gave bad signature for %s key %lu",
+			    __func__, sshkey_type(ctx->keys[i]), (unsigned long) i);
 			goto out;
 		}
 		/* Key is good. Mark it as 'seen' */
@@ -2380,8 +2380,8 @@
 		ndone++;
 	}
 	if (ndone != ctx->nnew)
-		fatal("%s: ndone != ctx->nnew (%zu / %zu)", __func__,
-		    ndone, ctx->nnew);  /* Shouldn't happen */
+		fatal("%s: ndone != ctx->nnew (%lu / %lu)", __func__,
+		    (unsigned long) ndone, (unsigned long) ctx->nnew);  /* Shouldn't happen */
 	ssh_packet_check_eom(ssh);
 
 	/* Make the edits to known_hosts */
@@ -2478,8 +2478,8 @@
 		/* Key is good, record it */
 		if ((tmp = reallocarray(ctx->keys, ctx->nkeys + 1,
 		    sizeof(*ctx->keys))) == NULL)
-			fatal("%s: reallocarray failed nkeys = %zu",
-			    __func__, ctx->nkeys);
+			fatal("%s: reallocarray failed nkeys = %lu",
+			    __func__, (unsigned long) ctx->nkeys);
 		ctx->keys = tmp;
 		ctx->keys[ctx->nkeys++] = key;
 		key = NULL;
@@ -2514,8 +2514,8 @@
 			ctx->nnew++;
 	}
 
-	debug3("%s: %zu keys from server: %zu new, %zu retained. %zu to remove",
-	    __func__, ctx->nkeys, ctx->nnew, ctx->nkeys - ctx->nnew, ctx->nold);
+	debug3("%s: %lu keys from server: %lu new, %lu retained. %lu to remove",
+	    __func__, (unsigned long) ctx->nkeys, (unsigned long) ctx->nnew, (unsigned long) (ctx->nkeys - ctx->nnew), (unsigned long) ctx->nold);
 
 	if (ctx->nnew == 0 && ctx->nold != 0) {
 		/* We have some keys to remove. Just do it. */
@@ -2525,8 +2525,8 @@
 		 * We have received hitherto-unseen keys from the server.
 		 * Ask the server to confirm ownership of the private halves.
 		 */
-		debug3("%s: asking server to prove ownership for %zu keys",
-		    __func__, ctx->nnew);
+		debug3("%s: asking server to prove ownership for %lu keys",
+		    __func__, (unsigned long) ctx->nnew);
 		if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 ||
 		    (r = sshpkt_put_cstring(ssh,
 		    "hostkeys-prove-00@openssh.com")) != 0 ||
--- dns.c	Mon Mar 20 03:39:27 2017
+++ dns.c	Mon Jul 31 00:40:02 2017
@@ -326,9 +326,9 @@
 		if (dns_read_key(&rdata_pubkey_algorithm, &rdata_digest_type,
 		    &rdata_digest, &rdata_digest_len, key)) {
 			if (generic) {
-				fprintf(f, "%s IN TYPE%d \\# %zu %02x %02x ",
+				fprintf(f, "%s IN TYPE%d \\# %lu %02x %02x ",
 				    hostname, DNS_RDATATYPE_SSHFP,
-				    2 + rdata_digest_len,
+				    (unsigned long) (2 + rdata_digest_len),
 				    rdata_pubkey_algorithm, rdata_digest_type);
 			} else {
 				fprintf(f, "%s IN SSHFP %d %d ", hostname,
--- hmac.c	Mon Mar 20 03:39:27 2017
+++ hmac.c	Mon Jul 31 00:40:01 2017
@@ -154,7 +154,7 @@
 
 	if (memcmp(e, digest, elen)) {
 		for (i = 0; i < elen; i++)
-			printf("[%zu] %2.2x %2.2x\n", i, e[i], digest[i]);
+			printf("[%lu] %2.2x %2.2x\n", (unsigned long) i, e[i], digest[i]);
 		printf("mismatch\n");
 	} else
 		printf("ok\n");
--- hostfile.c	Mon Mar 20 03:39:27 2017
+++ hostfile.c	Mon Jul 31 00:40:01 2017
@@ -108,8 +108,8 @@
 		return (-1);
 	}
 	if (ret != (int)ssh_hmac_bytes(SSH_DIGEST_SHA1)) {
-		debug2("extract_salt: expected salt len %zd, got %d",
-		    ssh_hmac_bytes(SSH_DIGEST_SHA1), ret);
+		debug2("extract_salt: expected salt len %lu, got %d",
+		    (unsigned long) ssh_hmac_bytes(SSH_DIGEST_SHA1), ret);
 		return (-1);
 	}
 
--- key.c	Mon Mar 20 03:39:27 2017
+++ key.c	Mon Jul 31 00:40:01 2017
@@ -122,7 +122,7 @@
 		return 0;
 	}
 	if (blen > INT_MAX)
-		fatal("%s: giant len %zu", __func__, blen);
+		fatal("%s: giant len %lu", __func__, (unsigned long) blen);
 	if (blobp != NULL)
 		*blobp = blob;
 	if (lenp != NULL)
@@ -149,7 +149,7 @@
 		return -1;
 	}
 	if (siglen > INT_MAX)
-		fatal("%s: giant len %zu", __func__, siglen);
+		fatal("%s: giant len %lu", __func__, (unsigned long) siglen);
 	if (sigp != NULL)
 		*sigp = sig;
 	if (lenp != NULL)
--- krl.c	Mon Mar 20 03:39:27 2017
+++ krl.c	Mon Jul 31 00:40:01 2017
@@ -741,7 +741,7 @@
 	/* Finally, output sections for revocations by public key/hash */
 	sshbuf_reset(sect);
 	RB_FOREACH(rb, revoked_blob_tree, &krl->revoked_keys) {
-		KRL_DBG(("%s: key len %zu ", __func__, rb->len));
+		KRL_DBG(("%s: key len %lu ", __func__, (unsigned long) rb->len));
 		if ((r = sshbuf_put_string(sect, rb->blob, rb->len)) != 0)
 			goto out;
 	}
@@ -752,7 +752,7 @@
 	}
 	sshbuf_reset(sect);
 	RB_FOREACH(rb, revoked_blob_tree, &krl->revoked_sha1s) {
-		KRL_DBG(("%s: hash len %zu ", __func__, rb->len));
+		KRL_DBG(("%s: hash len %lu ", __func__, (unsigned long) rb->len));
 		if ((r = sshbuf_put_string(sect, rb->blob, rb->len)) != 0)
 			goto out;
 	}
@@ -773,7 +773,7 @@
 		if ((r = sshkey_sign(sign_keys[i], &sblob, &slen,
 		    sshbuf_ptr(buf), sshbuf_len(buf), NULL, 0)) != 0)
 			goto out;
-		KRL_DBG(("%s: signature sig len %zu", __func__, slen));
+		KRL_DBG(("%s: signature sig len %lu", __func__, (unsigned long) slen));
 		if ((r = sshbuf_put_string(buf, sblob, slen)) != 0)
 			goto out;
 	}
--- monitor.c	Mon Mar 20 03:39:27 2017
+++ monitor.c	Mon Jul 31 00:40:02 2017
@@ -632,7 +632,7 @@
 		 * the client sent us.
 		 */
 		if (session_id2_len == 0) /* hostkeys is never first */
-			fatal("%s: bad data length: %zu", __func__, datlen);
+			fatal("%s: bad data length: %lu", __func__, (unsigned long) datlen);
 		if ((key = get_hostkey_public_by_index(keyid, ssh)) == NULL)
 			fatal("%s: no hostkey for index %d", __func__, keyid);
 		if ((sigbuf = sshbuf_new()) == NULL)
@@ -645,8 +645,8 @@
 			    "proof buffer: %s", __func__, ssh_err(r));
 		if (datlen != sshbuf_len(sigbuf) ||
 		    memcmp(p, sshbuf_ptr(sigbuf), sshbuf_len(sigbuf)) != 0)
-			fatal("%s: bad data length: %zu, hostkey proof len %zu",
-			    __func__, datlen, sshbuf_len(sigbuf));
+			fatal("%s: bad data length: %lu, hostkey proof len %lu",
+			    __func__, (unsigned long) datlen, (unsigned long) sshbuf_len(sigbuf));
 		sshbuf_free(sigbuf);
 		is_proof = 1;
 	}
@@ -673,8 +673,8 @@
 	} else
 		fatal("%s: no hostkey from index %d", __func__, keyid);
 
-	debug3("%s: %s signature %p(%zu)", __func__,
-	    is_proof ? "KEX" : "hostkey proof", signature, siglen);
+	debug3("%s: %s signature %p(%lu)", __func__,
+	    is_proof ? "KEX" : "hostkey proof", signature, (unsigned long) siglen);
 
 	sshbuf_reset(m);
 	if ((r = sshbuf_put_string(m, signature, siglen)) != 0)
--- monitor_fdpass.c	Mon Mar 20 03:39:27 2017
+++ monitor_fdpass.c	Mon Jul 31 00:40:01 2017
@@ -99,7 +99,7 @@
 	}
 
 	if (n != 1) {
-		error("%s: sendmsg: expected sent 1 got %zd", __func__, n);
+		error("%s: sendmsg: expected sent 1 got %ld", __func__, (long) n);
 		return -1;
 	}
 	return 0;
@@ -154,7 +154,7 @@
 	}
 
 	if (n != 1) {
-		error("%s: recvmsg: expected received 1 got %zd", __func__, n);
+		error("%s: recvmsg: expected received 1 got %ld", __func__, (long) n);
 		return -1;
 	}
 
--- packet.c	Mon Mar 20 03:39:27 2017
+++ packet.c	Mon Jul 31 00:40:01 2017
@@ -1187,8 +1187,8 @@
 		    (r = sshbuf_putb(state->outgoing_packet,
 		    state->compression_buffer)) != 0)
 			goto out;
-		DBG(debug("compression: raw %d compressed %zd", len,
-		    sshbuf_len(state->outgoing_packet)));
+		DBG(debug("compression: raw %d compressed %ld", len,
+		    (long) sshbuf_len(state->outgoing_packet)));
 	}
 
 	/* sizeof (packet_len + pad_len + payload) */
@@ -1625,8 +1625,8 @@
 
 	/* Test check bytes. */
 	if (len != sshbuf_len(state->incoming_packet)) {
-		error("%s: len %d != sshbuf_len %zd", __func__,
-		    len, sshbuf_len(state->incoming_packet));
+		error("%s: len %d != sshbuf_len %ld", __func__,
+		    len, (long) sshbuf_len(state->incoming_packet));
 		if ((r = sshpkt_disconnect(ssh, "invalid packet length")) != 0 ||
 		    (r = ssh_packet_write_wait(ssh)) != 0)
 			return r;
@@ -1887,8 +1887,8 @@
 	    ((r = sshbuf_consume_end(state->incoming_packet, padlen)) != 0))
 		goto out;
 
-	DBG(debug("input: len before de-compress %zd",
-	    sshbuf_len(state->incoming_packet)));
+	DBG(debug("input: len before de-compress %ld",
+	    (long) sshbuf_len(state->incoming_packet)));
 	if (comp && comp->enabled) {
 		sshbuf_reset(state->compression_buffer);
 		if ((r = uncompress_buffer(ssh, state->incoming_packet,
@@ -1898,8 +1898,8 @@
 		if ((r = sshbuf_putb(state->incoming_packet,
 		    state->compression_buffer)) != 0)
 			goto out;
-		DBG(debug("input: len after de-compress %zd",
-		    sshbuf_len(state->incoming_packet)));
+		DBG(debug("input: len after de-compress %ld",
+		    (long) sshbuf_len(state->incoming_packet)));
 	}
 	/*
 	 * get packet type, implies consume.
--- regress/misc/kexfuzz/kexfuzz.c	Mon Mar 20 03:39:27 2017
+++ regress/misc/kexfuzz/kexfuzz.c	Mon Jul 31 00:40:01 2017
@@ -84,8 +84,8 @@
 			    1, dumpfile) != 1)
 				err(1, "fwrite body %s", ctx->dump_path);
 			if (do_debug) {
-				printf("***** dumped packet type %u len %zu\n",
-				    *typep, sshbuf_len(packet));
+				printf("***** dumped packet type %u len %lu\n",
+				    *typep, (unsigned long) sshbuf_len(packet));
 			}
 			fclose(dumpfile);
 			/* No point in continuing */
--- regress/netcat.c	Mon Mar 20 03:39:27 2017
+++ regress/netcat.c	Mon Jul 31 00:40:01 2017
@@ -1037,7 +1037,7 @@
 			}
 			err(1, "sendmsg");
 		} else if (r == -1)
-			errx(1, "sendmsg: unexpected return value %zd", r);
+			errx(1, "sendmsg: unexpected return value %ld", (long) r);
 		else
 			break;
 	}
@@ -1485,11 +1485,11 @@
 		buf[2] = SOCKS_NOAUTH;
 		cnt = atomicio(vwrite, proxyfd, buf, 3);
 		if (cnt != 3)
-			err(1, "write failed (%zu/3)", cnt);
+			err(1, "write failed (%lu/3)", (unsigned long) cnt);
 
 		cnt = atomicio(read, proxyfd, buf, 2);
 		if (cnt != 2)
-			err(1, "read failed (%zu/3)", cnt);
+			err(1, "read failed (%lu/3)", (unsigned long) cnt);
 
 		if (buf[1] == SOCKS_NOMETHOD)
 			errx(1, "authentication method negotiation failed");
@@ -1538,11 +1538,11 @@
 
 		cnt = atomicio(vwrite, proxyfd, buf, wlen);
 		if (cnt != wlen)
-			err(1, "write failed (%zu/%zu)", cnt, wlen);
+			err(1, "write failed (%lu/%lu)", (unsigned long) cnt, (unsigned long) wlen);
 
 		cnt = atomicio(read, proxyfd, buf, 4);
 		if (cnt != 4)
-			err(1, "read failed (%zu/4)", cnt);
+			err(1, "read failed (%lu/4)", (unsigned long) cnt);
 		if (buf[1] != 0)
 			errx(1, "connection failed, SOCKS error %d", buf[1]);
 		switch (buf[3]) {
@@ -1549,12 +1549,12 @@
 		case SOCKS_IPV4:
 			cnt = atomicio(read, proxyfd, buf + 4, 6);
 			if (cnt != 6)
-				err(1, "read failed (%zu/6)", cnt);
+				err(1, "read failed (%lu/6)", (unsigned long) cnt);
 			break;
 		case SOCKS_IPV6:
 			cnt = atomicio(read, proxyfd, buf + 4, 18);
 			if (cnt != 18)
-				err(1, "read failed (%zu/18)", cnt);
+				err(1, "read failed (%lu/18)", (unsigned long) cnt);
 			break;
 		default:
 			errx(1, "connection failed, unsupported address type");
@@ -1574,11 +1574,11 @@
 
 		cnt = atomicio(vwrite, proxyfd, buf, wlen);
 		if (cnt != wlen)
-			err(1, "write failed (%zu/%zu)", cnt, wlen);
+			err(1, "write failed (%lu/%lu)", (unsigned long) cnt, (unsigned long) wlen);
 
 		cnt = atomicio(read, proxyfd, buf, 8);
 		if (cnt != 8)
-			err(1, "read failed (%zu/8)", cnt);
+			err(1, "read failed (%lu/8)", (unsigned long) cnt);
 		if (buf[1] != 90)
 			errx(1, "connection failed, SOCKS error %d", buf[1]);
 	} else if (socksv == -1) {
@@ -1604,7 +1604,7 @@
 
 		cnt = atomicio(vwrite, proxyfd, buf, r);
 		if (cnt != (size_t)r)
-			err(1, "write failed (%zu/%d)", cnt, r);
+			err(1, "write failed (%lu/%d)", (unsigned long) cnt, r);
 
 		if (authretry > 1) {
 			char resp[1024];
@@ -1622,7 +1622,7 @@
 				errx(1, "Proxy auth response too long");
 			r = strlen(buf);
 			if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != (size_t)r)
-				err(1, "write failed (%zu/%d)", cnt, r);
+				err(1, "write failed (%lu/%d)", (unsigned long) cnt, r);
 		}
 
 		/* Terminate headers */
--- regress/unittests/hostkeys/test_iterate.c	Mon Mar 20 03:39:27 2017
+++ regress/unittests/hostkeys/test_iterate.c	Mon Jul 31 00:40:01 2017
@@ -59,8 +59,8 @@
 	u_int expected_status, expected_match;
 	int expected_keytype;
 
-	test_subtest_info("entry %zu/%zu, file line %ld",
-	    ctx->i + 1, ctx->nexpected, l->linenum);
+	test_subtest_info("entry %lu/%lu, file line %ld",
+	    (unsigned long) (ctx->i + 1), (unsigned long) ctx->nexpected, l->linenum);
 
 	for (;;) {
 		ASSERT_SIZE_T_LT(ctx->i, ctx->nexpected);
--- regress/unittests/kex/test_kex.c	Mon Mar 20 03:39:27 2017
+++ regress/unittests/kex/test_kex.c	Mon Jul 31 00:40:01 2017
@@ -46,7 +46,7 @@
 			return 0;
 		buf = ssh_output_ptr(from, &len);
 		if (do_debug)
-			printf("%zu", len);
+			printf("%lu", (unsigned long) len);
 		if (len == 0)
 			return 0;
 		if ((r = ssh_output_consume(from, len)) != 0 ||
--- regress/unittests/sshkey/test_sshkey.c	Mon Mar 20 03:39:27 2017
+++ regress/unittests/sshkey/test_sshkey.c	Mon Jul 31 00:40:01 2017
@@ -154,8 +154,8 @@
 	};
 
 	for (i = 0; i < (sizeof(lens)/sizeof(lens[0])); i++) {
-		test_subtest_info("%s key, banana length %zu",
-		    sshkey_type(k), lens[i]);
+		test_subtest_info("%s key, banana length %lu",
+		    sshkey_type(k), (unsigned long) lens[i]);
 		banana(buf, lens[i]);
 		signature_test(k, bad, sig_alg, buf, lens[i]);
 	}
--- regress/unittests/test_helper/fuzz.c	Mon Mar 20 03:39:27 2017
+++ regress/unittests/test_helper/fuzz.c	Mon Jul 31 00:40:01 2017
@@ -107,45 +107,45 @@
 
 	switch (fuzz->strategy) {
 	case FUZZ_1_BIT_FLIP:
-		snprintf(s, n, "%s case %zu of %zu (bit: %zu)\n",
+		snprintf(s, n, "%s case %lu of %lu (bit: %lu)\n",
 		    fuzz_ntop(fuzz->strategy),
-		    fuzz->o1, fuzz->slen * 8, fuzz->o1);
+		    (unsigned long) fuzz->o1, (unsigned long) (fuzz->slen * 8), (unsigned long) fuzz->o1);
 		return 0;
 	case FUZZ_2_BIT_FLIP:
-		snprintf(s, n, "%s case %llu of %llu (bits: %zu, %zu)\n",
+		snprintf(s, n, "%s case %llu of %llu (bits: %lu, %lu)\n",
 		    fuzz_ntop(fuzz->strategy),
 		    (((fuzz_ullong)fuzz->o2) * fuzz->slen * 8) + fuzz->o1,
 		    ((fuzz_ullong)fuzz->slen * 8) * fuzz->slen * 8,
-		    fuzz->o1, fuzz->o2);
+		    (unsigned long) fuzz->o1, (unsigned long) fuzz->o2);
 		return 0;
 	case FUZZ_1_BYTE_FLIP:
-		snprintf(s, n, "%s case %zu of %zu (byte: %zu)\n",
+		snprintf(s, n, "%s case %lu of %lu (byte: %lu)\n",
 		    fuzz_ntop(fuzz->strategy),
-		    fuzz->o1, fuzz->slen, fuzz->o1);
+		    (unsigned long) fuzz->o1, (unsigned long) fuzz->slen, (unsigned long) fuzz->o1);
 		return 0;
 	case FUZZ_2_BYTE_FLIP:
-		snprintf(s, n, "%s case %llu of %llu (bytes: %zu, %zu)\n",
+		snprintf(s, n, "%s case %llu of %llu (bytes: %lu, %lu)\n",
 		    fuzz_ntop(fuzz->strategy),
 		    (((fuzz_ullong)fuzz->o2) * fuzz->slen) + fuzz->o1,
 		    ((fuzz_ullong)fuzz->slen) * fuzz->slen,
-		    fuzz->o1, fuzz->o2);
+		    (unsigned long) fuzz->o1, (unsigned long) fuzz->o2);
 		return 0;
 	case FUZZ_TRUNCATE_START:
-		snprintf(s, n, "%s case %zu of %zu (offset: %zu)\n",
+		snprintf(s, n, "%s case %lu of %lu (offset: %lu)\n",
 		    fuzz_ntop(fuzz->strategy),
-		    fuzz->o1, fuzz->slen, fuzz->o1);
+		    (unsigned long) fuzz->o1, (unsigned long) fuzz->slen, (unsigned long) fuzz->o1);
 		return 0;
 	case FUZZ_TRUNCATE_END:
-		snprintf(s, n, "%s case %zu of %zu (offset: %zu)\n",
+		snprintf(s, n, "%s case %lu of %lu (offset: %lu)\n",
 		    fuzz_ntop(fuzz->strategy),
-		    fuzz->o1, fuzz->slen, fuzz->o1);
+		    (unsigned long) fuzz->o1, (unsigned long) fuzz->slen, (unsigned long) fuzz->o1);
 		return 0;
 	case FUZZ_BASE64:
 		assert(fuzz->o2 < sizeof(fuzz_b64chars) - 1);
-		snprintf(s, n, "%s case %llu of %llu (offset: %zu char: %c)\n",
+		snprintf(s, n, "%s case %llu of %llu (offset: %lu char: %c)\n",
 		    fuzz_ntop(fuzz->strategy),
 		    (fuzz->o1 * (fuzz_ullong)64) + fuzz->o2,
-		    fuzz->slen * (fuzz_ullong)64, fuzz->o1,
+		    fuzz->slen * (fuzz_ullong)64, (unsigned long) fuzz->o1,
 		    fuzz_b64chars[fuzz->o2]);
 		return 0;
 	default:
@@ -190,9 +190,9 @@
 		abort();
 	}
 	fputs(buf, stderr);
-	fprintf(stderr, "fuzz original %p len = %zu\n", fuzz->seed, fuzz->slen);
+	fprintf(stderr, "fuzz original %p len = %lu\n", fuzz->seed, (unsigned long) fuzz->slen);
 	dump(fuzz->seed, fuzz->slen);
-	fprintf(stderr, "fuzz context %p len = %zu\n", fuzz, fuzz_len(fuzz));
+	fprintf(stderr, "fuzz context %p len = %lu\n", fuzz, (unsigned long) fuzz_len(fuzz));
 	dump(fuzz_ptr(fuzz), fuzz_len(fuzz));
 }
 
@@ -260,8 +260,8 @@
 static int
 fuzz_strategy_done(struct fuzz *fuzz)
 {
-	FUZZ_DBG(("fuzz = %p, strategy = %s, o1 = %zu, o2 = %zu, slen = %zu",
-	    fuzz, fuzz_ntop(fuzz->strategy), fuzz->o1, fuzz->o2, fuzz->slen));
+	FUZZ_DBG(("fuzz = %p, strategy = %s, o1 = %lu, o2 = %lu, slen = %lu",
+	    fuzz, fuzz_ntop(fuzz->strategy), (unsigned long) fuzz->o1, (unsigned long) fuzz->o2, (unsigned long) fuzz->slen));
 
 	switch (fuzz->strategy) {
 	case FUZZ_1_BIT_FLIP:
@@ -286,8 +286,8 @@
 	u_int i;
 
 	FUZZ_DBG(("start, fuzz = %p, strategy = %s, strategies = 0x%lx, "
-	    "o1 = %zu, o2 = %zu, slen = %zu", fuzz, fuzz_ntop(fuzz->strategy),
-	    (u_long)fuzz->strategies, fuzz->o1, fuzz->o2, fuzz->slen));
+	    "o1 = %lu, o2 = %lu, slen = %lu", fuzz, fuzz_ntop(fuzz->strategy),
+	    (u_long)fuzz->strategies, (unsigned long) fuzz->o1, (unsigned long) fuzz->o2, (unsigned long) fuzz->slen));
 
 	if (fuzz->strategy == 0 || fuzz_strategy_done(fuzz)) {
 		/* If we are just starting out, we need to allocate too */
@@ -373,8 +373,8 @@
 	}
 
 	FUZZ_DBG(("done, fuzz = %p, strategy = %s, strategies = 0x%lx, "
-	    "o1 = %zu, o2 = %zu, slen = %zu", fuzz, fuzz_ntop(fuzz->strategy),
-	    (u_long)fuzz->strategies, fuzz->o1, fuzz->o2, fuzz->slen));
+	    "o1 = %lu, o2 = %lu, slen = %lu", fuzz, fuzz_ntop(fuzz->strategy),
+	    (u_long)fuzz->strategies, (unsigned long) fuzz->o1, (unsigned long) fuzz->o2, (unsigned long) fuzz->slen));
 }
 
 int
--- regress/unittests/test_helper/test_helper.c	Mon Mar 20 03:39:27 2017
+++ regress/unittests/test_helper/test_helper.c	Mon Jul 31 00:40:01 2017
@@ -328,8 +328,8 @@
 	r = strcmp(aa1, aa2);
 	TEST_CHECK_INT(r, pred);
 	test_header(file, line, a1, a2, "STRING", pred);
-	fprintf(stderr, "%12s = %s (len %zu)\n", a1, aa1, strlen(aa1));
-	fprintf(stderr, "%12s = %s (len %zu)\n", a2, aa2, strlen(aa2));
+	fprintf(stderr, "%12s = %s (len %lu)\n", a1, aa1, (unsigned long) strlen(aa1));
+	fprintf(stderr, "%12s = %s (len %lu)\n", a2, aa2, (unsigned long) strlen(aa2));
 	test_die();
 }
 
@@ -365,8 +365,8 @@
 	r = memcmp(aa1, aa2, l);
 	TEST_CHECK_INT(r, pred);
 	test_header(file, line, a1, a2, "STRING", pred);
-	fprintf(stderr, "%12s = %s (len %zu)\n", a1, tohex(aa1, MIN(l, 256)), l);
-	fprintf(stderr, "%12s = %s (len %zu)\n", a2, tohex(aa2, MIN(l, 256)), l);
+	fprintf(stderr, "%12s = %s (len %lu)\n", a1, tohex(aa1, MIN(l, 256)), (unsigned long) l);
+	fprintf(stderr, "%12s = %s (len %lu)\n", a2, tohex(aa2, MIN(l, 256)), (unsigned long) l);
 	test_die();
 }
 
@@ -400,9 +400,9 @@
 	r = memvalcmp(aa1, v, l, &where);
 	TEST_CHECK_INT(r, pred);
 	test_header(file, line, a1, NULL, "MEM_ZERO", pred);
-	fprintf(stderr, "%20s = %s%s (len %zu)\n", a1,
-	    tohex(aa1, MIN(l, 20)), l > 20 ? "..." : "", l);
-	snprintf(tmp, sizeof(tmp), "(%s)[%zu]", a1, where);
+	fprintf(stderr, "%20s = %s%s (len %lu)\n", a1,
+	    tohex(aa1, MIN(l, 20)), l > 20 ? "..." : "", (unsigned long) l);
+	snprintf(tmp, sizeof(tmp), "(%s)[%lu]", a1, (unsigned long) where);
 	fprintf(stderr, "%20s = 0x%02x (expected 0x%02x)\n", tmp,
 	    ((u_char *)aa1)[where], v);
 	test_die();
@@ -425,8 +425,8 @@
 {
 	TEST_CHECK(aa1, aa2, pred);
 	test_header(file, line, a1, a2, "SIZE_T", pred);
-	fprintf(stderr, "%12s = %zu\n", a1, aa1);
-	fprintf(stderr, "%12s = %zu\n", a2, aa2);
+	fprintf(stderr, "%12s = %lu\n", a1, (unsigned long) aa1);
+	fprintf(stderr, "%12s = %lu\n", a2, (unsigned long) aa2);
 	test_die();
 }
 
--- sftp-client.c	Mon Mar 20 03:39:27 2017
+++ sftp-client.c	Mon Jul 31 00:40:02 2017
@@ -112,7 +112,7 @@
 	struct iovec iov[2];
 
 	if (sshbuf_len(m) > SFTP_MAX_MSG_LENGTH)
-		fatal("Outbound message too long %zu", sshbuf_len(m));
+		fatal("Outbound message too long %lu", (unsigned long) sshbuf_len(m));
 
 	/* Send length first */
 	put_u32(mlen, sshbuf_len(m));
@@ -1326,7 +1326,7 @@
 			    (unsigned long long)req->offset + len - 1);
 			if (len > req->len)
 				fatal("Received more data than asked for "
-				    "%zu > %zu", len, req->len);
+				    "%lu > %lu", (unsigned long) len, (unsigned long) req->len);
 			if ((lseek(local_fd, req->offset, SEEK_SET) == -1 ||
 			    atomicio(vwrite, local_fd, data, len) != len) &&
 			    !write_error) {
--- sftp-common.c	Mon Mar 20 03:39:27 2017
+++ sftp-common.c	Mon Jul 31 00:40:01 2017
@@ -140,8 +140,8 @@
 			if ((r = sshbuf_get_cstring(b, &type, NULL)) != 0 ||
 			    (r = sshbuf_get_string(b, &data, &dlen)) != 0)
 				return r;
-			debug3("Got file attribute \"%.100s\" len %zu",
-			    type, dlen);
+			debug3("Got file attribute \"%.100s\" len %lu",
+			    type, (unsigned long) dlen);
 			free(type);
 			free(data);
 		}
--- sftp-server.c	Mon Mar 20 03:39:27 2017
+++ sftp-server.c	Mon Jul 31 00:40:02 2017
@@ -783,8 +783,8 @@
 	    (r = sshbuf_get_string(iqueue, &data, &len)) != 0)
 		fatal("%s: buffer error: %s", __func__, ssh_err(r));
 
-	debug("request %u: write \"%s\" (handle %d) off %llu len %zu",
-	    id, handle_to_name(handle), handle, (unsigned long long)off, len);
+	debug("request %u: write \"%s\" (handle %d) off %llu len %lu",
+	    id, handle_to_name(handle), handle, (unsigned long long)off, (unsigned long) len);
 	fd = handle_to_fd(handle);
 
 	if (fd < 0)
--- ssh-keygen.c	Mon Mar 20 03:39:27 2017
+++ ssh-keygen.c	Mon Jul 31 00:40:01 2017
@@ -420,8 +420,8 @@
 		fatal("%s: buffer error: %s", __func__, ssh_err(r));
 	bytes = (bignum_bits + 7) / 8;
 	if (sshbuf_len(b) < bytes)
-		fatal("%s: input buffer too small: need %d have %zu",
-		    __func__, bytes, sshbuf_len(b));
+		fatal("%s: input buffer too small: need %d have %lu",
+		    __func__, bytes, (unsigned long) sshbuf_len(b));
 	if (BN_bin2bn(sshbuf_ptr(b), bytes, value) == NULL)
 		fatal("%s: BN_bin2bn failed", __func__);
 	if ((r = sshbuf_consume(b, bytes)) != 0)
@@ -1865,8 +1865,8 @@
 			printf(" %s\n", arg);
 			free(arg);
 		} else {
-			printf(" UNKNOWN OPTION (len %zu)\n",
-			    sshbuf_len(option));
+			printf(" UNKNOWN OPTION (len %lu)\n",
+			    (unsigned long) sshbuf_len(option));
 			sshbuf_reset(option);
 		}
 		free(name);
--- sshbuf-misc.c	Mon Mar 20 03:39:27 2017
+++ sshbuf-misc.c	Mon Jul 31 00:40:01 2017
@@ -42,7 +42,7 @@
 	const u_char *p = (const u_char *)s;
 
 	for (i = 0; i < len; i += 16) {
-		fprintf(f, "%.4zu: ", i);
+		fprintf(f, "%.4lu: ", (unsigned long) i);
 		for (j = i; j < i + 16; j++) {
 			if (j < len)
 				fprintf(f, "%02x ", p[j]);
@@ -65,7 +65,7 @@
 void
 sshbuf_dump(struct sshbuf *buf, FILE *f)
 {
-	fprintf(f, "buffer %p len = %zu\n", buf, sshbuf_len(buf));
+	fprintf(f, "buffer %p len = %lu\n", buf, (unsigned long) sshbuf_len(buf));
 	sshbuf_dump_data(sshbuf_ptr(buf), sshbuf_len(buf), f);
 }
 
--- sshbuf.c	Mon Mar 20 03:39:27 2017
+++ sshbuf.c	Mon Jul 31 00:40:02 2017
@@ -235,7 +235,7 @@
 	u_char *dp;
 	int r;
 
-	SSHBUF_DBG(("set max buf = %p len = %zu", buf, max_size));
+	SSHBUF_DBG(("set max buf = %p len = %lu", buf, (unsigned long) max_size));
 	if ((r = sshbuf_check_sanity(buf)) != 0)
 		return r;
 	if (max_size == buf->max_size)
@@ -254,7 +254,7 @@
 		if (rlen > max_size)
 			rlen = max_size;
 		explicit_bzero(buf->d + buf->size, buf->alloc - buf->size);
-		SSHBUF_DBG(("new alloc = %zu", rlen));
+		SSHBUF_DBG(("new alloc = %lu", (unsigned long) rlen));
 		if ((dp = realloc(buf->d, rlen)) == NULL)
 			return SSH_ERR_ALLOC_FAIL;
 		buf->cd = buf->d = dp;
@@ -322,7 +322,7 @@
 	u_char *dp;
 	int r;
 
-	SSHBUF_DBG(("allocate buf = %p len = %zu", buf, len));
+	SSHBUF_DBG(("allocate buf = %p len = %lu", buf, (unsigned long) len));
 	if ((r = sshbuf_check_reserve(buf, len)) != 0)
 		return r;
 	/*
@@ -340,10 +340,10 @@
 	 */
 	need = len + buf->size - buf->alloc;
 	rlen = ROUNDUP(buf->alloc + need, SSHBUF_SIZE_INC);
-	SSHBUF_DBG(("need %zu initial rlen %zu", need, rlen));
+	SSHBUF_DBG(("need %lu initial rlen %lu", (unsigned long) need, (unsigned long) rlen));
 	if (rlen > buf->max_size)
 		rlen = buf->alloc + need;
-	SSHBUF_DBG(("adjusted rlen %zu", rlen));
+	SSHBUF_DBG(("adjusted rlen %lu", (unsigned long) rlen));
 	if ((dp = realloc(buf->d, rlen)) == NULL) {
 		SSHBUF_DBG(("realloc fail"));
 		return SSH_ERR_ALLOC_FAIL;
@@ -367,7 +367,7 @@
 	if (dpp != NULL)
 		*dpp = NULL;
 
-	SSHBUF_DBG(("reserve buf = %p len = %zu", buf, len));
+	SSHBUF_DBG(("reserve buf = %p len = %lu", buf, (unsigned long) len));
 	if ((r = sshbuf_allocate(buf, len)) != 0)
 		return r;
 
@@ -383,7 +383,7 @@
 {
 	int r;
 
-	SSHBUF_DBG(("len = %zu", len));
+	SSHBUF_DBG(("len = %lu", (unsigned long) len));
 	if ((r = sshbuf_check_sanity(buf)) != 0)
 		return r;
 	if (len == 0)
@@ -400,7 +400,7 @@
 {
 	int r;
 
-	SSHBUF_DBG(("len = %zu", len));
+	SSHBUF_DBG(("len = %lu", (unsigned long) len));
 	if ((r = sshbuf_check_sanity(buf)) != 0)
 		return r;
 	if (len == 0)
--- sshbuf.h	Mon Mar 20 03:39:27 2017
+++ sshbuf.h	Mon Jul 31 00:40:02 2017
@@ -336,9 +336,10 @@
 
 # ifdef SSHBUF_DEBUG
 #  define SSHBUF_TELL(what) do { \
-		printf("%s:%d %s: %s size %zu alloc %zu off %zu max %zu\n", \
+		printf("%s:%d %s: %s size %lu alloc %lu off %lu max %lu\n", \
 		    __FILE__, __LINE__, __func__, what, \
-		    buf->size, buf->alloc, buf->off, buf->max_size); \
+		    (unsigned long) buf->size, (unsigned long) buf->alloc, \
+                    (unsigned long) buf->off, (unsigned long) buf->max_size); \
 		fflush(stdout); \
 	} while (0)
 #  define SSHBUF_DBG(x) do { \
--- sshd.c	Mon Mar 20 03:39:27 2017
+++ sshd.c	Mon Jul 31 00:40:02 2017
@@ -922,8 +922,8 @@
 	struct sshbuf *m;
 	int r;
 
-	debug3("%s: entering fd = %d config len %zu", __func__, fd,
-	    sshbuf_len(conf));
+	debug3("%s: entering fd = %d config len %lu", __func__, fd,
+	    (unsigned long) sshbuf_len(conf));
 
 	/*
 	 * Protocol from reexec master to child:
--- xmalloc.c	Mon Mar 20 03:39:27 2017
+++ xmalloc.c	Mon Jul 31 00:40:02 2017
@@ -45,7 +45,7 @@
 		fatal("xmalloc: zero size");
 	ptr = malloc(size);
 	if (ptr == NULL)
-		fatal("xmalloc: out of memory (allocating %zu bytes)", size);
+		fatal("xmalloc: out of memory (allocating %lu bytes)", (unsigned long) size);
 	return ptr;
 }
 
@@ -60,8 +60,8 @@
 		fatal("xcalloc: nmemb * size > SIZE_MAX");
 	ptr = calloc(nmemb, size);
 	if (ptr == NULL)
-		fatal("xcalloc: out of memory (allocating %zu bytes)",
-		    size * nmemb);
+		fatal("xcalloc: out of memory (allocating %lu bytes)",
+		    (unsigned long) (size * nmemb));
 	return ptr;
 }
 
@@ -72,8 +72,8 @@
 
 	new_ptr = reallocarray(ptr, nmemb, size);
 	if (new_ptr == NULL)
-		fatal("xreallocarray: out of memory (%zu elements of %zu bytes)",
-		    nmemb, size);
+		fatal("xreallocarray: out of memory (%lu elements of %lu bytes)",
+		    (unsigned long) nmemb, (unsigned long) size);
 	return new_ptr;
 }
 
