From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id oEYnM6LPOWMmcwAAbAwnHQ (envelope-from ) for ; Sun, 02 Oct 2022 19:51:30 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 2NZFM6LPOWMmZQAA9RJhRA (envelope-from ) for ; Sun, 02 Oct 2022 19:51:30 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id AE0671D761 for ; Sun, 2 Oct 2022 19:51:30 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 3A10D5E221; Sun, 2 Oct 2022 17:51:21 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id DD3B05DD5B for ; Sun, 2 Oct 2022 17:51:17 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 30C165FBC6; Sun, 2 Oct 2022 13:51:16 -0400 (EDT) Received: (nullmailer pid 541067 invoked by uid 1000); Sun, 02 Oct 2022 17:51:14 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 2/2] lib: add better diagnostics for over long filenames. Date: Sun, 2 Oct 2022 14:51:03 -0300 Message-Id: <20221002175103.541050-2-david@tethera.net> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20221002175103.541050-1-david@tethera.net> References: <20221002175103.541050-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: R2FUVBXUKVDJQQM6DZCFXHSUIGX5S25W X-Message-ID-Hash: R2FUVBXUKVDJQQM6DZCFXHSUIGX5S25W X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: jao@gnu.org X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664733090; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=LdhDkg64TbP4SPZHp7UA12n5Ruf9++vJ84toEKS6k4Y=; b=sNvHHUMCGlGq9yVSakn6116mhjCxBhk5l+BY0cirai+mEeEInOJ/kvVCSqvFtaS1Wycb3W TKDMG3bam5nV/gr1AddukG5CLMppixj+oWJpWwLzS86S5qOJZ+1YZFevovj+T2JkHU5tQl ny0ayCvcYXoqreApMuQQAfa32ZTnQ/X/YoL7Xl86zs36NpPnqhyOdJqIC63CsaN9apGGLx kcdfhnDm6WOQjGsAwSyH0lstW1ZTMJ2QVOF32/q2qEr1hjsJqB57dAd+ArpmRZUjih7nKk kvhhDGdo35e9Mrg1LoB3Q6y2lUXXfRNM5UxUKku35YIy6PCetvcaRJAbvBjtBA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664733090; a=rsa-sha256; cv=none; b=XMEpma7iQT5IuWTdmXf1l+09dEq3a115TPYdyO9pmOjZ2mzm8WqncE3R+lIc2wo7thUt+n mLYyWGt2FaA/IUZVeLOhykYBBUV/u+c4VNXAF06hT6X1f5noU+ReySnRwapf8l0Jy0kBS1 rcrqNArA4Ss21YeeDP6aRxrq5sagTk5ElTpTnEKWoa7FC8khyfxdoHT4eM0JuC7KRsiR9j GgcjFnlVtZmO5M/YscHyrcBfAtlpfBRoaxdZ1rnfHJR6npE48Vx1ePihYij/YkYddjY2HX eBcv2tQwqh47HIs8nW/ycNVFyhRer9Wwo4096lcIqwhwIOvD9LIfLVqZT8rtSA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.04 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: AE0671D761 X-Spam-Score: -1.04 X-Migadu-Scanner: scn1.migadu.com X-TUID: eLBWSuOt5mpi Previously we just crashed with an internal error. With this change, the caller can handle it better, although the error code could be further improved. --- lib/message.cc | 15 +++++++++++---- test/T050-new.sh | 1 - 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index 1c87f8c0..0e6ea809 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -941,6 +941,7 @@ _notmuch_message_add_filename (notmuch_message_t *message, { const char *relative, *directory; notmuch_status_t status; + notmuch_private_status_t private_status; void *local = talloc_new (message); char *direntry; @@ -964,10 +965,16 @@ _notmuch_message_add_filename (notmuch_message_t *message, /* New file-direntry allows navigating to this message with * notmuch_directory_get_child_files() . */ - status = COERCE_STATUS (_notmuch_message_add_term (message, "file-direntry", direntry), - "adding file-direntry term"); - if (status) - return status; + private_status =_notmuch_message_add_term (message, "file-direntry", direntry); + switch (private_status) { + case NOTMUCH_PRIVATE_STATUS_SUCCESS: + break; + case NOTMUCH_PRIVATE_STATUS_TERM_TOO_LONG: + _notmuch_database_log(message->notmuch, "filename too long for file-direntry term: %s\n", filename); + return NOTMUCH_STATUS_FILE_ERROR; + default: + return COERCE_STATUS (private_status, "adding file-direntry term"); + } status = _notmuch_message_add_folder_terms (message, directory); if (status) diff --git a/test/T050-new.sh b/test/T050-new.sh index 74890928..bf086609 100755 --- a/test/T050-new.sh +++ b/test/T050-new.sh @@ -384,7 +384,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "Long file names have reasonable diagnostics" -test_subtest_known_broken printf -v name 'f%.0s' {1..234} generate_message "[filename]=$name" notmuch new 2>&1 | notmuch_dir_sanitize >OUTPUT -- 2.35.2