Leighs code comfirmed insecure.

Discussion in 'C++' started by Paul, Apr 29, 2011.

  1. Paul

    Paul Guest

    If Leigh'd been able to communicate properly he would've learned something
    because what I was trying to explain to him about his code was that his
    templates do no type checking.
    The code he presented has big fancy templates that look very professional
    with charT and traits parameteters, all in avery similar in style to the C++
    std lib. But they only look good, they don't actually do anything, all his
    templates do is open the functions to accept almost anytype.
    If his templates had any real value they'd ensure typechecking and enhance
    the security of the functions making code more robust and catch more errors
    at compile time.

    Here is an example of just how misleading Leighs code can be , and an
    example of how he presents himself as some expert and makes his code appear
    professional, but its actually very easy to hack and break.

    By displaying these flaws in Legihs code I do not intend to harm him or
    attack him in person , I did originally attempt to have a resonable
    discussion about the code, but as you can see from other threads I was
    attacked with an onslaught of personal abuse.


    #include <iostream>
    #include <vector>
    #include <string>
    #include <algorithm>


    template <typename FwdIter1, typename FwdIter2, typename ResultContainer>
    inline FwdIter1 tokens(FwdIter1 aFirst, FwdIter1 aLast, FwdIter2
    aDelimeterFirst, FwdIter2 aDelimiterLast, ResultContainer& aTokens,
    std::size_t aMaxTokens = 0, bool aSkipEmptyTokens = true, bool
    aDelimeterIsSubsequence = false)
    {
    if (aFirst >= aLast)
    return aFirst;
    typedef typename ResultContainer::value_type value_type;
    if (aDelimeterFirst == aDelimiterLast)
    {
    aTokens.push_back(value_type(aFirst, aLast));
    return aLast;
    }
    FwdIter1 b = aFirst;
    FwdIter1 e = aDelimeterIsSubsequence ? std::search(b, aLast,
    aDelimeterFirst, aDelimiterLast) : std::find_first_of(b, aLast,
    aDelimeterFirst, aDelimiterLast);
    std::size_t tokens = 0;
    while(e != aLast && (aMaxTokens == 0 || tokens < aMaxTokens))
    {
    if (b == e && !aSkipEmptyTokens)
    {
    aTokens.push_back(value_type(b, b));
    ++tokens;
    }
    else if (b != e)
    {
    aTokens.push_back(value_type(b, e));
    ++tokens;
    }
    b = e;
    for (std::size_t i = aDelimeterIsSubsequence ?
    std::distance(aDelimeterFirst, aDelimiterLast) : 1; i > 0; --i)
    ++b;
    e = aDelimeterIsSubsequence ? std::search(b, aLast, aDelimeterFirst,
    aDelimiterLast) : std::find_first_of(b, aLast, aDelimeterFirst,
    aDelimiterLast);
    }
    if (b != e && (aMaxTokens == 0 || tokens < aMaxTokens))
    {
    aTokens.push_back(value_type(b, e));
    b = e;
    }
    return b;
    }

    template <typename CharT, typename Traits, typename Alloc, typename
    ResultContainer>
    inline void tokens(const std::basic_string<CharT, Traits, Alloc>&
    aLine, const std::basic_string<CharT, Traits, Alloc>& aDelimeter,
    ResultContainer& aTokens, std::size_t aMaxTokens = 0, bool
    aSkipEmptyTokens = true, bool aDelimeterIsSubsequence = false)
    {
    tokens(aLine.begin(), aLine.end(), aDelimeter.begin(),
    aDelimeter.end(), aTokens, aMaxTokens, aSkipEmptyTokens,
    aDelimeterIsSubsequence);
    }


    class Foo{
    public:
    Foo(){;}
    Foo(char* arg1, char* arg2){security_breaker();}
    Foo(const Foo& rhs){;}
    ~Foo(){}
    void security_breaker(){std::cout<<"code does what it likes.....\n";}
    };

    int main(){
    std::vector<Foo> v1;
    char c[4] = {'A','B','\0','D'};
    double arr[5];

    tokens(c, c+sizeof(c), arr, arr+sizeof(arr), v1);
    }


    I did originally intend helping Leigh by showing him how to do it correctly
    , but **** him . He gave me shit and was nasty so he won't be learning
    anything from here :)
    Paul, Apr 29, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. danpres2k
    Replies:
    0
    Views:
    1,465
    danpres2k
    Aug 13, 2003
  2. =?Utf-8?B?VmluY2UgTWVsZQ==?=

    Secure page with Insecure Elements

    =?Utf-8?B?VmluY2UgTWVsZQ==?=, Jun 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    2,350
    Codepuller
    Jul 6, 2004
  3. UJ
    Replies:
    1
    Views:
    421
  4. scorpion
    Replies:
    0
    Views:
    526
    scorpion
    Apr 27, 2004
  5. Noen

    Running insecure python code

    Noen, Feb 26, 2004, in forum: Python
    Replies:
    7
    Views:
    398
    Mark 'Kamikaze' Hughes
    Mar 6, 2004
Loading...

Share This Page