From d85647ff0e7f7e44ca21ac70341d4a0bb76132db Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Tue, 8 Jan 2013 00:12:43 +0200 Subject: [PATCH] Re: [PATCH] string-util: Disallow empty prefixes in parse_boolean_term --- 2f/fb633f2519f835f4bbe6876b9f3599e63b6455 | 94 +++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 2f/fb633f2519f835f4bbe6876b9f3599e63b6455 diff --git a/2f/fb633f2519f835f4bbe6876b9f3599e63b6455 b/2f/fb633f2519f835f4bbe6876b9f3599e63b6455 new file mode 100644 index 000000000..67b30e668 --- /dev/null +++ b/2f/fb633f2519f835f4bbe6876b9f3599e63b6455 @@ -0,0 +1,94 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id A0573431FAE + for ; Mon, 7 Jan 2013 14:12:55 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id aOhyYbizu7HT for ; + Mon, 7 Jan 2013 14:12:51 -0800 (PST) +Received: from mail-la0-f48.google.com (mail-la0-f48.google.com + [209.85.215.48]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 0C4C2431FAF + for ; Mon, 7 Jan 2013 14:12:50 -0800 (PST) +Received: by mail-la0-f48.google.com with SMTP id ej20so17094892lab.21 + for ; Mon, 07 Jan 2013 14:12:48 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=x-received:from:to:cc:subject:in-reply-to:references:user-agent + :date:message-id:mime-version:content-type:x-gm-message-state; + bh=W67jVbpVazWg8zbuuNYvfqsu4yjM6pOWZBhQfb/bqiQ=; + b=D08cDpdhSg8UlPZ+bQ8vjzLI6kUe6MlCHnwqVQdCZ+g84Q9iHYMP8gGAOfnz4qiC2l + h/+cs8ns4TN+BqOMYHnDpnmQ8dQTtZQ3bOpfdlN3SRDkauuW0Vtckr/qFWSXy0is0XFf + WHHAwIyoH4KQpGK6AxB4S0158ZrgD7pby2vPEXHu/rRMOCinQgvaTqJ3uiVWM9VHIQ98 + jTuHKP3yYZoVEtEP8nlvuPhjljWidiHQNXX/pc6H5vZymgxmwXz7OA0Dgr3Ftdn/J8Ko + c88ypkuDpX4d1jqPL+vtHIx+is7NlhDXviTYHOSDVKKUK9ZNFNIC1AxvN1XqeORBV55B + 0K7w== +X-Received: by 10.152.125.136 with SMTP id mq8mr59789967lab.41.1357596766759; + Mon, 07 Jan 2013 14:12:46 -0800 (PST) +Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi. + [80.223.81.27]) + by mx.google.com with ESMTPS id ee5sm21849707lbb.14.2013.01.07.14.12.44 + (version=SSLv3 cipher=OTHER); Mon, 07 Jan 2013 14:12:45 -0800 (PST) +From: Jani Nikula +To: Austin Clements , notmuch@notmuchmail.org +Subject: Re: [PATCH] string-util: Disallow empty prefixes in + parse_boolean_term +In-Reply-To: <1357593640-32122-1-git-send-email-amdragon@mit.edu> +References: <1357593640-32122-1-git-send-email-amdragon@mit.edu> +User-Agent: Notmuch/0.14+211~gc8d6546 (http://notmuchmail.org) Emacs/24.2.1 + (x86_64-pc-linux-gnu) +Date: Tue, 08 Jan 2013 00:12:43 +0200 +Message-ID: <87ip78ej6s.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain +X-Gm-Message-State: + ALoCoQlfmd4MXYahAi+gd7FV3R0WRMJw99BvQHl4taF6MjAAXSH5nOP5zrihxzQ+bQL5ktTfa3Mr +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 07 Jan 2013 22:12:55 -0000 + +On Mon, 07 Jan 2013, Austin Clements wrote: +> Xapian doesn't consider ":abc" to be a prefixed term. This makes +> parse_boolean_term similarly reject queries with an empty prefix. + +LGTM, +Jani. + +> --- +> util/string-util.c | 2 +- +> 1 file changed, 1 insertion(+), 1 deletion(-) +> +> diff --git a/util/string-util.c b/util/string-util.c +> index aba9aa8..a5622d7 100644 +> --- a/util/string-util.c +> +++ b/util/string-util.c +> @@ -127,7 +127,7 @@ parse_boolean_term (void *ctx, const char *str, +> /* Parse prefix */ +> str = skip_space (str); +> const char *pos = strchr (str, ':'); +> - if (! pos) +> + if (! pos || pos == str) +> goto FAIL; +> *prefix_out = talloc_strndup (ctx, str, pos - str); +> if (! *prefix_out) { +> -- +> 1.7.10.4 -- 2.26.2