News for hackers. Stuff that matters.
Re:Deconstructing K&R C (2010) by judofyr on Saturday January 05, 2013 @09:25AM (#5012690)

    A = {'a','b','\0'}; B = {'a', 'b', '\0'};  safercopy(2, A, 2, B);
    A = {'a','b'}; B = {'a', 'b', '\0'};  safercopy(2, A, 2, B);
    A = {'a','b','\0'}; B = {'a', 'b'};  safercopy(2, A, 2, B);
    A = {'a','b'}; B = {'a', 'b'};  safercopy(2, A, 2, B);
This analysis only tries different values of A and B, not the lengths. A proper analysis of "for what values does it fail" should include all parameters. What happens if you do `safercopy(3, A, 2, B)` or `safercopy(3, A, 3, B)`?
Re:Deconstructing K&R C (2010) by tcarney on Saturday January 05, 2013 @11:13AM (#5012995)
Exactly what I noticed. The "safer" function relies on the length arguments being correct, just as the copy function relied on the strings being null-terminated. The safer function is more explicit so less prone to error, but both rely on the programmer doing the right thing, which is what he was trying to avoid...
Re:Deconstructing K&R C (2010) by yxhuvud on Saturday January 05, 2013 @03:17PM (#5013888)
The good part is that valgrind will hopefully find that it read outside bounds immediately, as opposed to code depending on correct string termination which will work with correct test cases.