Commit ae45d3693b49de05b472c00fbe0d6e3ff5d16ecc
1 parent
af325d36
using strncpy is *always* a bad idea
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4727 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
2 additions
and
3 deletions
vl.c
... | ... | @@ -3394,8 +3394,7 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str, |
3394 | 3394 | #ifndef _WIN32 |
3395 | 3395 | if (is_unix) { |
3396 | 3396 | char path[109]; |
3397 | - strncpy(path, uaddr.sun_path, 108); | |
3398 | - path[108] = 0; | |
3397 | + pstrcpy(path, sizeof(path), uaddr.sun_path); | |
3399 | 3398 | unlink(path); |
3400 | 3399 | } else |
3401 | 3400 | #endif |
... | ... | @@ -5075,7 +5074,7 @@ static int drive_init(struct drive_opt *arg, int snapshot, |
5075 | 5074 | } |
5076 | 5075 | |
5077 | 5076 | if (get_param_value(buf, sizeof(buf), "if", str)) { |
5078 | - strncpy(devname, buf, sizeof(devname)); | |
5077 | + pstrcpy(devname, sizeof(devname), buf); | |
5079 | 5078 | if (!strcmp(buf, "ide")) { |
5080 | 5079 | type = IF_IDE; |
5081 | 5080 | max_devs = MAX_IDE_DEVS; | ... | ... |