diff options
author | balrog <balrog> | 2008-11-08 23:57:26 +0000 |
---|---|---|
committer | balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-11-08 23:57:26 +0000 |
commit | c1abb8a5c658ffaa90a90b45f3e44f96347da182 (patch) | |
tree | 411921f0a692b94e550cfdcadd141d4d04840630 /qemu | |
parent | 16d37c9b8d0674269617e1e7d90ed71f5fdbeea5 (diff) |
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.
Diffstat (limited to 'qemu')
-rw-r--r-- | qemu/cutils.c | 12 | ||||
-rw-r--r-- | qemu/hw/bt-hci.c | 10 | ||||
-rw-r--r-- | qemu/qemu-common.h | 1 |
3 files changed, 5 insertions, 18 deletions
diff --git a/qemu/cutils.c b/qemu/cutils.c index 8fcb62ef..9ef2fa62 100644 --- a/qemu/cutils.c +++ b/qemu/cutils.c @@ -50,18 +50,6 @@ char *pstrcat(char *buf, int buf_size, const char *s) return buf; } -/* strdup with a limit */ -char *pstrdup(const char *str, size_t buf_size) -{ - size_t len; - char *buf; - - len = MIN(buf_size, strlen(str)); - buf = qemu_malloc(len); - pstrcpy(buf, len, str); - return buf; -} - int strstart(const char *str, const char *val, const char **ptr) { const char *p, *q; diff --git a/qemu/hw/bt-hci.c b/qemu/hw/bt-hci.c index 121fabf4..71c12b85 100644 --- a/qemu/hw/bt-hci.c +++ b/qemu/hw/bt-hci.c @@ -1137,7 +1137,7 @@ static void bt_hci_reset(struct bt_hci_s *hci) hci->device.inquiry_scan = 0; hci->device.page_scan = 0; if (hci->device.lmp_name) - qemu_free((void *) hci->device.lmp_name); + free((void *) hci->device.lmp_name); hci->device.lmp_name = 0; hci->device.class[0] = 0x00; hci->device.class[1] = 0x00; @@ -1387,7 +1387,7 @@ static inline void bt_hci_event_complete_read_local_name(struct bt_hci_s *hci) params.status = HCI_SUCCESS; memset(params.name, 0, sizeof(params.name)); if (hci->device.lmp_name) - pstrcpy(params.name, sizeof(params.name), hci->device.lmp_name); + strncpy(params.name, hci->device.lmp_name, sizeof(params.name)); bt_hci_event_complete(hci, ¶ms, READ_LOCAL_NAME_RP_SIZE); } @@ -1815,8 +1815,8 @@ static void bt_submit_hci(struct HCIInfo *info, LENGTH_CHECK(change_local_name); if (hci->device.lmp_name) - qemu_free((void *) hci->device.lmp_name); - hci->device.lmp_name = pstrdup(PARAM(change_local_name, name), + free((void *) hci->device.lmp_name); + hci->device.lmp_name = strndup(PARAM(change_local_name, name), sizeof(PARAM(change_local_name, name))); bt_hci_event_complete_status(hci, HCI_SUCCESS); break; @@ -2191,7 +2191,7 @@ static void bt_hci_done(struct HCIInfo *info) bt_device_done(&hci->device); if (hci->device.lmp_name) - qemu_free((void *) hci->device.lmp_name); + free((void *) hci->device.lmp_name); /* Be gentle and send DISCONNECT to all connected peers and those * currently waiting for us to accept or reject a connection request. diff --git a/qemu/qemu-common.h b/qemu/qemu-common.h index f23d7b4c..2b7f7e1a 100644 --- a/qemu/qemu-common.h +++ b/qemu/qemu-common.h @@ -89,7 +89,6 @@ int qemu_timedate_diff(struct tm *tm); /* cutils.c */ void pstrcpy(char *buf, int buf_size, const char *str); char *pstrcat(char *buf, int buf_size, const char *s); -char *pstrdup(const char *str, size_t buf_size); int strstart(const char *str, const char *val, const char **ptr); int stristart(const char *str, const char *val, const char **ptr); time_t mktimegm(struct tm *tm); |