The man page of strncpy
states:
char *strncpy(char *dest, const char *src, size_t n);
The strcpy() and strncpy() functions return a pointer to the destination string dest.
Is it possible that strncpy(buff, "something", 9) == 0
be true if char buff[100]
?
UPDATE
I also consider it as not very probable but it's part of a program that I should make to bufferoverflow and this condition stays on my way to achieve this.
No.
Judging from the facts that
NULL
's value equals 0
A NULL
pointer shall not point to a valid object. From the C11 standard, §6.3.2.3:
[...] a null pointer [,] is guaranteed to compare unequal to a pointer to any object or function.
and that the corresponding man page does not mention the possibility of dest == NULL
,
it is not allowed to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With