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 567C9431FB6 for ; Thu, 5 Apr 2012 04:49:50 -0700 (PDT) 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 r8Ct+56Siksd for ; Thu, 5 Apr 2012 04:49:49 -0700 (PDT) Received: from mail-qc0-f181.google.com (mail-qc0-f181.google.com [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id B9F56431FAE for ; Thu, 5 Apr 2012 04:49:49 -0700 (PDT) Received: by qcsk26 with SMTP id k26so914560qcs.26 for ; Thu, 05 Apr 2012 04:49:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type:x-gm-message-state; bh=WIL/pphOGlbGKX82FJX6p/HT1+uR88ccUaHaFWRZ+lE=; b=XU/4/28o3mFB6WAz1nw/NUxs3ZIsvqkLiVb11q0/WGo/b4GBVtZrxCHevjnIcjKBVc SKUDmj+Rknl/XpHXtzbe47tBf7nRDbC/14Plvem8K1Wvjl8+BlBlMOaRg3DQsFVLVwa6 +nlY5WhqCSPH0Xtr7MVutObFQ4VD4iZqzLVlT4ulCIqJDoltaJTui37xngZkYCoLe+Qh 5/fp2CgM+4GrqR0nNle9xYeDn6z9bQ5XOOM7uR+GBJ7c7/oEkARyVu07QncfmzG98EqJ gjoIw3NRcss17YeCtPVDvDSMowcuCi6i6znzSJnLNzv5MLltn6sQl3JOTXYc+az/lUXE h+XA== Received: by 10.224.209.74 with SMTP id gf10mr3698421qab.8.1333626588029; Thu, 05 Apr 2012 04:49:48 -0700 (PDT) Received: from localhost (nikula.org. [92.243.24.172]) by mx.google.com with ESMTPS id dv7sm5777813qab.15.2012.04.05.04.49.44 (version=SSLv3 cipher=OTHER); Thu, 05 Apr 2012 04:49:46 -0700 (PDT) From: Jani Nikula To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 2/8] hex-escape: be more strict about the format while decoding In-Reply-To: <87fwcitnuk.fsf@zancas.localnet> References: <81e543344ffe8e2761afd57a2268e8b362f4aef4.1333231401.git.jani@nikula.org>User-Agent: Notmuch/0.12+70~g46e73fe (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) <87fwcitnuk.fsf@zancas.localnet> User-Agent: Notmuch/0.11.1+222~ga47a98c (http://notmuchmail.org) Emacs/23.1.1 (i686-pc-linux-gnu) Date: Thu, 05 Apr 2012 11:49:42 +0000 Message-ID: <87hawyxusp.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gm-Message-State: ALoCoQk4hl1VmUgwkmYyXD8wUAov4w10HLFgYJkUmk4x1+FtC/HdFpRW1Y0OtpMeCvOlyrwYW7bX 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: Thu, 05 Apr 2012 11:49:50 -0000 On Thu, 05 Apr 2012 08:33:23 -0300, David Bremner wrote: > Jani Nikula writes: > > > Signed-off-by: Jani Nikula > > > > --- > > > > This could be folded to "hex-escape: (en|de)code strings to/from > > restricted character set". > > That's probably a good plan. > > > - if (len < 3) > > + if (!isxdigit ((unsigned char) p[1]) || > > + !isxdigit ((unsigned char) p[2])) > > What happens if there are not two characters after the escape? Is this > relying on calling isxdigit on the null terminator? It is, and technically there's nothing wrong with that. Would you prefer explicit checks for '\0' in the if condition, for clarity? Or a comment about it? Jani.