From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id AD42742116A for ; Sat, 31 Mar 2012 15:17:46 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" 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 vhKQHZBVHNAT for ; Sat, 31 Mar 2012 15:17:44 -0700 (PDT) Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 8793E421169 for ; Sat, 31 Mar 2012 15:17:44 -0700 (PDT) Received: by mail-bk0-f53.google.com with SMTP id j4so1547751bkw.26 for ; Sat, 31 Mar 2012 15:17:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references:x-gm-message-state; bh=TsWGZWrnVGOmi6Hm2//eppuh7J+3J7ubp5qYb9lfNsE=; b=ndYveopER/q3TvEJKyyoFttUMQ0XiGa5zxnc6Br+OfXhOiZwcm4pd3Pa8EPZ2pKNot Ro37GboFsKXSZ1ik56OrA+Gm7ELG+wZaavl1EDO7XtLXh/yyboUJogm7LYiLz5USO3Do yeuQkGGBvn007iH6adkB9Hkg9EjxqWm3g28jkVbxkCLi4yZETvW2sBgB8d3ElPRxgpSc 6SUgbb9EmX9sK2DlD5S1Vqv5SyiMZ/4ZdujJNzW9Riv6RXbCBsdMy466HCXp/Ky9osQx QbiPuIdTBT2HhyAL+hImkCPwMotLtjb9T3iJHe90P20B83IWfCx0qTceH1RX+WPNMW3H 3Jkg== Received: by 10.204.136.220 with SMTP id s28mr1372652bkt.94.1333232264112; Sat, 31 Mar 2012 15:17:44 -0700 (PDT) Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi. [84.248.80.253]) by mx.google.com with ESMTPS id t17sm28577387bke.6.2012.03.31.15.17.42 (version=SSLv3 cipher=OTHER); Sat, 31 Mar 2012 15:17:43 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH 2/8] hex-escape: be more strict about the format while decoding Date: Sun, 1 Apr 2012 01:17:22 +0300 Message-Id: <81e543344ffe8e2761afd57a2268e8b362f4aef4.1333231401.git.jani@nikula.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQmfxuZvT1x2Htd1paR0/3dHTZdkBmQ7wApmqQA5m6l2kupym56MEVv1Zbl73oij2Xf5Qdrh 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: Sat, 31 Mar 2012 22:17:46 -0000 Signed-off-by: Jani Nikula --- This could be folded to "hex-escape: (en|de)code strings to/from restricted character set". --- util/hex-escape.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/util/hex-escape.c b/util/hex-escape.c index 6c1260b..9de79df 100644 --- a/util/hex-escape.c +++ b/util/hex-escape.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "error_util.h" #include "hex-escape.h" @@ -131,18 +132,18 @@ hex_decode (void *ctx, const char *in, char **out, size_t * out_size) char *endp; - if (len < 3) + if (!isxdigit ((unsigned char) p[1]) || + !isxdigit ((unsigned char) p[2])) return HEX_SYNTAX_ERROR; buf[0] = p[1]; buf[1] = p[2]; - *q = strtol (buf, &endp, 16); + *q = strtoul (buf, &endp, 16); if (endp != buf + 2) return HEX_SYNTAX_ERROR; - len -= 3; p += 3; q++; } else { -- 1.7.5.4