Vlákno názorů k článku
Curl zakazuje ve svém kódu funkci strcpy(), použije vlastní bezpečnější náhradu od pc2005 - The strncpy() function is similar, except that at...

  • Článek je starý, nové názory již nelze přidávat.
  • 5. 1. 2026 22:57

    pc2005


    The strncpy() function is similar, except that at most n bytes of src are copied. Warning: If there is no null byte among the first n bytes of src, the string placed in dest will not be null-terminated.

    To je z bláta do louže :-D

  • 6. 1. 2026 4:28

    Wasper

    Je ale třeba si uvědomit (a moc se to neví), že strncpy nikdy neměla sloužit jako bezpečný strcpy pro C-type stringy, ale výlučně pro vytvoření fixed size stringu (nebo jak se tomu správně nadává).

    Dlužno podotknout, že jsem v tomhle tisíciletí viděl přesně dva projekty, které tuhle formu používají (resp posílají po síti).

    <hr />

    The C library strncpy() function accepts three parameters(dest, src, n) which copies up the n characters from the string pointed to, by src to dest. In this case, the length of src is less than that of n, the remainder of dest will be added with null bytes.

    6. 1. 2026, 04:29 editováno autorem komentáře