Spot the bug C
1
// Copy len bytes of src into a fixed-size field; never overflow dst.
2
void copy_field(char *dst, size_t cap, const char *src, int len) {3
if (len > (int)cap) // reject anything longer than the field
4
return;
5
memcpy(dst, src, len);
6
}