From ce595235cb6633de476673e4f6856325d00aa232 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Tue, 21 Aug 2001 11:39:45 +0000 Subject: [PATCH] Display a better error message when snprintf() returns < 0 Pointed out by: bde --- usr.bin/ftp/fetch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index 870c3ff54575..31d5649b8b42 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -282,7 +282,11 @@ url_get(origline, proxyenv) printf("Requesting %s (via %s)\n", origline, proxyenv); len = snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\r\n\r\n", proxy ? "" : "/", path); - if (len < 0 || write(s, buf, len) < len) { + if (len < 0) { + warnx("Failed to format HTTP request"); + goto cleanup_url_get; + } + if (write(s, buf, len) < len) { warn("Writing HTTP request"); goto cleanup_url_get; }