Commit 793a10a2d435cb3e5d52bc06cf0a06191006148a
1 parent
4fc9af53
Revert r5532, r5536 and a piece of r5531.
The use of strncat and strndup was correct, pstrcpy and pstrdup wasn't. I'll try to restore building on non-gnu OSes in a later commit. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5651 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
5 additions
and
18 deletions
cutils.c
| ... | ... | @@ -50,18 +50,6 @@ char *pstrcat(char *buf, int buf_size, const char *s) |
| 50 | 50 | return buf; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | -/* strdup with a limit */ | |
| 54 | -char *pstrdup(const char *str, size_t buf_size) | |
| 55 | -{ | |
| 56 | - size_t len; | |
| 57 | - char *buf; | |
| 58 | - | |
| 59 | - len = MIN(buf_size, strlen(str)); | |
| 60 | - buf = qemu_malloc(len); | |
| 61 | - pstrcpy(buf, len, str); | |
| 62 | - return buf; | |
| 63 | -} | |
| 64 | - | |
| 65 | 53 | int strstart(const char *str, const char *val, const char **ptr) |
| 66 | 54 | { |
| 67 | 55 | const char *p, *q; | ... | ... |
hw/bt-hci.c
| ... | ... | @@ -1137,7 +1137,7 @@ static void bt_hci_reset(struct bt_hci_s *hci) |
| 1137 | 1137 | hci->device.inquiry_scan = 0; |
| 1138 | 1138 | hci->device.page_scan = 0; |
| 1139 | 1139 | if (hci->device.lmp_name) |
| 1140 | - qemu_free((void *) hci->device.lmp_name); | |
| 1140 | + free((void *) hci->device.lmp_name); | |
| 1141 | 1141 | hci->device.lmp_name = 0; |
| 1142 | 1142 | hci->device.class[0] = 0x00; |
| 1143 | 1143 | hci->device.class[1] = 0x00; |
| ... | ... | @@ -1387,7 +1387,7 @@ static inline void bt_hci_event_complete_read_local_name(struct bt_hci_s *hci) |
| 1387 | 1387 | params.status = HCI_SUCCESS; |
| 1388 | 1388 | memset(params.name, 0, sizeof(params.name)); |
| 1389 | 1389 | if (hci->device.lmp_name) |
| 1390 | - pstrcpy(params.name, sizeof(params.name), hci->device.lmp_name); | |
| 1390 | + strncpy(params.name, hci->device.lmp_name, sizeof(params.name)); | |
| 1391 | 1391 | |
| 1392 | 1392 | bt_hci_event_complete(hci, ¶ms, READ_LOCAL_NAME_RP_SIZE); |
| 1393 | 1393 | } |
| ... | ... | @@ -1815,8 +1815,8 @@ static void bt_submit_hci(struct HCIInfo *info, |
| 1815 | 1815 | LENGTH_CHECK(change_local_name); |
| 1816 | 1816 | |
| 1817 | 1817 | if (hci->device.lmp_name) |
| 1818 | - qemu_free((void *) hci->device.lmp_name); | |
| 1819 | - hci->device.lmp_name = pstrdup(PARAM(change_local_name, name), | |
| 1818 | + free((void *) hci->device.lmp_name); | |
| 1819 | + hci->device.lmp_name = strndup(PARAM(change_local_name, name), | |
| 1820 | 1820 | sizeof(PARAM(change_local_name, name))); |
| 1821 | 1821 | bt_hci_event_complete_status(hci, HCI_SUCCESS); |
| 1822 | 1822 | break; |
| ... | ... | @@ -2191,7 +2191,7 @@ static void bt_hci_done(struct HCIInfo *info) |
| 2191 | 2191 | bt_device_done(&hci->device); |
| 2192 | 2192 | |
| 2193 | 2193 | if (hci->device.lmp_name) |
| 2194 | - qemu_free((void *) hci->device.lmp_name); | |
| 2194 | + free((void *) hci->device.lmp_name); | |
| 2195 | 2195 | |
| 2196 | 2196 | /* Be gentle and send DISCONNECT to all connected peers and those |
| 2197 | 2197 | * currently waiting for us to accept or reject a connection request. | ... | ... |
qemu-common.h
| ... | ... | @@ -89,7 +89,6 @@ int qemu_timedate_diff(struct tm *tm); |
| 89 | 89 | /* cutils.c */ |
| 90 | 90 | void pstrcpy(char *buf, int buf_size, const char *str); |
| 91 | 91 | char *pstrcat(char *buf, int buf_size, const char *s); |
| 92 | -char *pstrdup(const char *str, size_t buf_size); | |
| 93 | 92 | int strstart(const char *str, const char *val, const char **ptr); |
| 94 | 93 | int stristart(const char *str, const char *val, const char **ptr); |
| 95 | 94 | time_t mktimegm(struct tm *tm); | ... | ... |