Do strong types, in this case char prevent buffer overflow?
char a[100]
char b[100]
strcpy(a,unknownFunction); // unknownFunction could overflow b
// since its length is unknown
strcpy(b,a); // can b still overflow a with its now,
// potentially overflowed size?
No. strcpy()
just keeps going until it finds a null-terminator ('\0'
). If b[]
doesn't contain one, it will just walk through random memory until it eventually finds one.
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