Commit be15b141e0dddd9f41e464ca98aef1b05b28cf6b

Authored by blueswir1
1 parent 9b4c14c3

Replace uses of strncpy (a GNU extension) with Qemu pstrcpy

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5531 c046a42c-6fe2-441c-8c8c-71466251a162
block-vmdk.c
@@ -344,7 +344,7 @@ static int vmdk_parent_open(BlockDriverState *bs, const char * filename) @@ -344,7 +344,7 @@ static int vmdk_parent_open(BlockDriverState *bs, const char * filename)
344 if ((end_name - p_name) > sizeof (s->hd->backing_file) - 1) 344 if ((end_name - p_name) > sizeof (s->hd->backing_file) - 1)
345 return -1; 345 return -1;
346 346
347 - strncpy(s->hd->backing_file, p_name, end_name - p_name); 347 + pstrcpy(s->hd->backing_file, end_name - p_name, p_name);
348 if (stat(s->hd->backing_file, &file_buf) != 0) { 348 if (stat(s->hd->backing_file, &file_buf) != 0) {
349 path_combine(parent_img_name, sizeof(parent_img_name), 349 path_combine(parent_img_name, sizeof(parent_img_name),
350 filename, s->hd->backing_file); 350 filename, s->hd->backing_file);
block-vvfat.c
@@ -625,7 +625,7 @@ static inline direntry_t* create_short_and_long_name(BDRVVVFATState* s, @@ -625,7 +625,7 @@ static inline direntry_t* create_short_and_long_name(BDRVVVFATState* s,
625 625
626 entry=array_get_next(&(s->directory)); 626 entry=array_get_next(&(s->directory));
627 memset(entry->name,0x20,11); 627 memset(entry->name,0x20,11);
628 - strncpy((char*)entry->name,filename,i); 628 + pstrcpy((char*)entry->name, i, filename);
629 629
630 if(j > 0) 630 if(j > 0)
631 for (i = 0; i < 3 && filename[j+1+i]; i++) 631 for (i = 0; i < 3 && filename[j+1+i]; i++)
hw/bt-hci.c
@@ -1385,7 +1385,7 @@ static inline void bt_hci_event_complete_read_local_name(struct bt_hci_s *hci) @@ -1385,7 +1385,7 @@ static inline void bt_hci_event_complete_read_local_name(struct bt_hci_s *hci)
1385 params.status = HCI_SUCCESS; 1385 params.status = HCI_SUCCESS;
1386 memset(params.name, 0, sizeof(params.name)); 1386 memset(params.name, 0, sizeof(params.name));
1387 if (hci->device.lmp_name) 1387 if (hci->device.lmp_name)
1388 - strncpy(params.name, hci->device.lmp_name, sizeof(params.name)); 1388 + pstrcpy(params.name, sizeof(params.name), hci->device.lmp_name);
1389 1389
1390 bt_hci_event_complete(hci, &params, READ_LOCAL_NAME_RP_SIZE); 1390 bt_hci_event_complete(hci, &params, READ_LOCAL_NAME_RP_SIZE);
1391 } 1391 }
linux-user/syscall.c
@@ -4993,7 +4993,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, @@ -4993,7 +4993,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
4993 if (tnamelen > 256) 4993 if (tnamelen > 256)
4994 tnamelen = 256; 4994 tnamelen = 256;
4995 /* XXX: may not be correct */ 4995 /* XXX: may not be correct */
4996 - strncpy(tde->d_name, de->d_name, tnamelen); 4996 + pstrcpy(tde->d_name, tnamelen, de->d_name);
4997 de = (struct linux_dirent *)((char *)de + reclen); 4997 de = (struct linux_dirent *)((char *)de + reclen);
4998 len -= reclen; 4998 len -= reclen;
4999 tde = (struct target_dirent *)((char *)tde + treclen); 4999 tde = (struct target_dirent *)((char *)tde + treclen);
slirp/udp.c
@@ -475,14 +475,14 @@ struct cu_header { @@ -475,14 +475,14 @@ struct cu_header {
475 type = omsg->type; 475 type = omsg->type;
476 OTOSIN(omsg, ctl_addr)->sin_port = addr.sin_port; 476 OTOSIN(omsg, ctl_addr)->sin_port = addr.sin_port;
477 OTOSIN(omsg, ctl_addr)->sin_addr = our_addr; 477 OTOSIN(omsg, ctl_addr)->sin_addr = our_addr;
478 - strncpy(omsg->l_name, getlogin(), NAME_SIZE_OLD); 478 + pstrcpy(omsg->l_name, NAME_SIZE_OLD, getlogin());
479 } else { /* new talk */ 479 } else { /* new talk */
480 omsg = (CTL_MSG_OLD *) buff; 480 omsg = (CTL_MSG_OLD *) buff;
481 nmsg = mtod(m, CTL_MSG *); 481 nmsg = mtod(m, CTL_MSG *);
482 type = nmsg->type; 482 type = nmsg->type;
483 OTOSIN(nmsg, ctl_addr)->sin_port = addr.sin_port; 483 OTOSIN(nmsg, ctl_addr)->sin_port = addr.sin_port;
484 OTOSIN(nmsg, ctl_addr)->sin_addr = our_addr; 484 OTOSIN(nmsg, ctl_addr)->sin_addr = our_addr;
485 - strncpy(nmsg->l_name, getlogin(), NAME_SIZE_OLD); 485 + pstrcpy(nmsg->l_name, NAME_SIZE_OLD, getlogin());
486 } 486 }
487 487
488 if (type == LOOK_UP) 488 if (type == LOOK_UP)
@@ -4446,7 +4446,7 @@ int tap_alloc(char *dev, size_t dev_size) @@ -4446,7 +4446,7 @@ int tap_alloc(char *dev, size_t dev_size)
4446 syslog(LOG_ERR, "Can't get flags\n"); 4446 syslog(LOG_ERR, "Can't get flags\n");
4447 4447
4448 snprintf (actual_name, 32, "tap%d", ppa); 4448 snprintf (actual_name, 32, "tap%d", ppa);
4449 - strncpy (ifr.lifr_name, actual_name, sizeof (ifr.lifr_name)); 4449 + pstrcpy(ifr.lifr_name, sizeof(ifr.lifr_name), actual_name);
4450 4450
4451 ifr.lifr_ppa = ppa; 4451 ifr.lifr_ppa = ppa;
4452 /* Assign ppa according to the unit number returned by tun device */ 4452 /* Assign ppa according to the unit number returned by tun device */
@@ -4489,7 +4489,7 @@ int tap_alloc(char *dev, size_t dev_size) @@ -4489,7 +4489,7 @@ int tap_alloc(char *dev, size_t dev_size)
4489 close (if_fd); 4489 close (if_fd);
4490 4490
4491 memset(&ifr, 0x0, sizeof(ifr)); 4491 memset(&ifr, 0x0, sizeof(ifr));
4492 - strncpy (ifr.lifr_name, actual_name, sizeof (ifr.lifr_name)); 4492 + pstrcpy(ifr.lifr_name, sizeof(ifr.lifr_name), actual_name);
4493 ifr.lifr_ip_muxid = ip_muxid; 4493 ifr.lifr_ip_muxid = ip_muxid;
4494 ifr.lifr_arp_muxid = arp_muxid; 4494 ifr.lifr_arp_muxid = arp_muxid;
4495 4495
@@ -2337,7 +2337,8 @@ int vnc_display_open(DisplayState *ds, const char *display) @@ -2337,7 +2337,8 @@ int vnc_display_open(DisplayState *ds, const char *display)
2337 if (start && (!end || (start < end))) { 2337 if (start && (!end || (start < end))) {
2338 int len = end ? end-(start+1) : strlen(start+1); 2338 int len = end ? end-(start+1) : strlen(start+1);
2339 char *path = qemu_malloc(len+1); 2339 char *path = qemu_malloc(len+1);
2340 - strncpy(path, start+1, len); 2340 +
  2341 + pstrcpy(path, len, start + 1);
2341 path[len] = '\0'; 2342 path[len] = '\0';
2342 VNC_DEBUG("Trying certificate path '%s'\n", path); 2343 VNC_DEBUG("Trying certificate path '%s'\n", path);
2343 if (vnc_set_x509_credential_dir(vs, path) < 0) { 2344 if (vnc_set_x509_credential_dir(vs, path) < 0) {