All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jean-Noël AVILA" <avila.jn@gmail.com>
To: git@vger.kernel.org
Subject: Re: [PATCH] attr: fix off-by-one directory component length calculation
Date: Tue, 15 Jan 2013 20:14:28 +0100	[thread overview]
Message-ID: <201301152014.28433.avila.jn@gmail.com> (raw)
In-Reply-To: <1358256924-31578-1-git-send-email-pclouds@gmail.com>

Thank you for the explanation.

I did not monitor the system calls when writing that patch. 
Where is the perf framework?

As the mistake is located in the "find_basename" function, I would propose a 
fix directly into it so that the output fits what the other functions expect.

Something in the line of:

diff --git a/attr.c b/attr.c
index d6d7190..b6e72f3 100644
--- a/attr.c
+++ b/attr.c
@@ -572,7 +572,7 @@ static const char *find_basename(const char *path)
                if (*cp == '/' && cp[1])
                        last_slash = cp;
        }
-       return last_slash ? last_slash + 1 : path;
+       return last_slash ? last_slash : path;
 }
 
 static void prepare_attr_stack(const char *path)
@@ -770,6 +770,10 @@ static void collect_all_attrs(const char *path)
                check_all_attr[i].value = ATTR__UNKNOWN;
 
        basename = find_basename(path);
+       /* the slash is included in the basename
+          so that it can be matched by a directory pattern */
+       if (basename != path)
+               basename++;
        pathlen = strlen(path);
        rem = attr_nr;
        for (stk = attr_stack; 0 < rem && stk; stk = stk->prev)

  parent reply	other threads:[~2013-01-15 19:15 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-15 13:35 [PATCH] attr: fix off-by-one directory component length calculation Nguyễn Thái Ngọc Duy
2013-01-15 16:17 ` Junio C Hamano
2013-01-15 19:14 ` Jean-Noël AVILA [this message]
2013-01-15 19:29   ` Junio C Hamano
2013-01-15 19:53     ` Jean-Noël AVILA
2013-01-15 20:49       ` Junio C Hamano
2013-01-15 23:24         ` Jeff King
2013-01-16  6:15           ` t9902 fails (Was: [PATCH] attr: fix off-by-one directory component length calculation) Torsten Bögershausen
2013-01-17 22:47             ` Jean-Noël AVILA
2013-01-18  0:04               ` Jonathan Nieder
2013-01-18  0:12                 ` t9902 fails Junio C Hamano
2013-01-18  5:20                 ` t9902 fails (Was: [PATCH] attr: fix off-by-one directory component length calculation) Torsten Bögershausen
2013-01-18 16:49                 ` t9902 fails Junio C Hamano
2013-01-18 20:15                   ` Junio C Hamano
2013-01-18 22:23                     ` Jean-Noël AVILA
2013-01-18 22:37                       ` Junio C Hamano
2013-01-18 22:57                         ` Junio C Hamano
2013-01-19  5:38                       ` Torsten Bögershausen
2013-01-19  7:52                         ` Re* " Junio C Hamano
2013-01-19  8:00                           ` [PATCH 1/2] help: include <common-cmds.h> only in one file Junio C Hamano
2013-01-19  8:02                             ` [PATCH 2/2] help --standard: list standard commands Junio C Hamano
2013-01-19 10:32                               ` Jean-Noël AVILA
2013-01-19 13:43                           ` Re* t9902 fails Jean-Noël AVILA
2013-01-19 10:23                         ` Jean-Noël AVILA
2013-01-16  1:08     ` [PATCH] attr: fix off-by-one directory component length calculation Duy Nguyen
2013-01-16  2:09       ` Duy Nguyen
2013-01-16  2:33         ` Junio C Hamano
2013-01-16  3:12           ` Duy Nguyen
2013-01-16  5:35             ` Junio C Hamano
2013-01-16  6:02               ` Duy Nguyen
2013-01-16 19:07                 ` Junio C Hamano
2013-01-16  1:03   ` Duy Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201301152014.28433.avila.jn@gmail.com \
    --to=avila.jn@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.