Loading ...
Sorry, an error occurred while loading the content.

should add __attribute__((alloc_size)) to functions using malloc() ?

Expand Messages
  • tyru
    Hi list. I have read a blog post about gcc extension. http://mkosaki.blog46.fc2.com/blog-entry-1228.html (Japanese) The blog title says _FORTIFY_SOURCE
    Message 1 of 3 , May 11, 2013
    • 0 Attachment
      Hi list.

      I have read a blog post about gcc extension.
      http://mkosaki.blog46.fc2.com/blog-entry-1228.html (Japanese)

      The blog title says "_FORTIFY_SOURCE without
      __attribute__((alloc_size)) doesn't make sense" .

      I've seen some "_FORTIFY_SOURCE" outputs while compiling Vim.
      Should we add __attribute__((alloc_size)) to functions using malloc(),
      and calloc() ?
      (original post doesn't say about calloc(), though)
      I also found alloc(), lalloc() in misc2.c which should be related for this.

      I don't understand Vim build system well yet.
      I hope someone would create a patch for this...

      Thanks

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Ken Takata
      Hi list, ... Here is a good example which uses __attribute__((alloc_size)). See the following commit to the Ruby s source code:
      Message 2 of 3 , May 11, 2013
      • 0 Attachment
        Hi list,

        2013/05/12 Sun 0:36:43 UTC+9 tyru wrote:
        > Hi list.
        >
        > I have read a blog post about gcc extension.
        > http://mkosaki.blog46.fc2.com/blog-entry-1228.html (Japanese)
        >
        > The blog title says "_FORTIFY_SOURCE without
        > __attribute__((alloc_size)) doesn't make sense" .
        >
        > I've seen some "_FORTIFY_SOURCE" outputs while compiling Vim.
        > Should we add __attribute__((alloc_size)) to functions using malloc(),
        > and calloc() ?
        > (original post doesn't say about calloc(), though)
        > I also found alloc(), lalloc() in misc2.c which should be related for this.
        >
        > I don't understand Vim build system well yet.
        > I hope someone would create a patch for this...
        >
        > Thanks

        Here is a good example which uses __attribute__((alloc_size)).
        See the following commit to the Ruby's source code:
        http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/defines.h?r1=40572&r2=40571&pathrev=40572
        This commit was written by the author of the blog post.

        However we can't apply this method directly to the Vim's source code,
        because we use cproto to generate *.pro.

        Thanks,
        Ken Takata

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Bram Moolenaar
        ... Please don t waste time on it. For Vim _FORTIFY_SOURCE doesn t really work. There are many structures that are allocated larger than they are defined.
        Message 3 of 3 , May 12, 2013
        • 0 Attachment
          Ken Takata wrote:

          > 2013/05/12 Sun 0:36:43 UTC+9 tyru wrote:
          > > Hi list.
          > >
          > > I have read a blog post about gcc extension.
          > > http://mkosaki.blog46.fc2.com/blog-entry-1228.html (Japanese)
          > >
          > > The blog title says "_FORTIFY_SOURCE without
          > > __attribute__((alloc_size)) doesn't make sense" .
          > >
          > > I've seen some "_FORTIFY_SOURCE" outputs while compiling Vim.
          > > Should we add __attribute__((alloc_size)) to functions using malloc(),
          > > and calloc() ?
          > > (original post doesn't say about calloc(), though)
          > > I also found alloc(), lalloc() in misc2.c which should be related for this.
          > >
          > > I don't understand Vim build system well yet.
          > > I hope someone would create a patch for this...
          > >
          > > Thanks
          >
          > Here is a good example which uses __attribute__((alloc_size)).
          > See the following commit to the Ruby's source code:
          > http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/defines.h?r1=40572&r2=40571&pathrev=40572
          > This commit was written by the author of the blog post.
          >
          > However we can't apply this method directly to the Vim's source code,
          > because we use cproto to generate *.pro.

          Please don't waste time on it. For Vim _FORTIFY_SOURCE doesn't really
          work. There are many structures that are allocated larger than they are
          defined. It will just be a lot of work to create false alarms.

          --
          [clop clop]
          MORTICIAN: Who's that then?
          CUSTOMER: I don't know.
          MORTICIAN: Must be a king.
          CUSTOMER: Why?
          MORTICIAN: He hasn't got shit all over him.
          The Quest for the Holy Grail (Monty Python)

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ an exciting new programming language -- http://www.Zimbu.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

          --
          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        Your message has been successfully submitted and would be delivered to recipients shortly.