Revision 2bd7318c
b/cutils.c | ||
---|---|---|
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 |
|
|
53 | 65 |
int strstart(const char *str, const char *val, const char **ptr) |
54 | 66 |
{ |
55 | 67 |
const char *p, *q; |
b/hw/bt-hci.c | ||
---|---|---|
1814 | 1814 |
|
1815 | 1815 |
if (hci->device.lmp_name) |
1816 | 1816 |
free((void *) hci->device.lmp_name); |
1817 |
hci->device.lmp_name = strndup(PARAM(change_local_name, name),
|
|
1817 |
hci->device.lmp_name = pstrdup(PARAM(change_local_name, name),
|
|
1818 | 1818 |
sizeof(PARAM(change_local_name, name))); |
1819 | 1819 |
bt_hci_event_complete_status(hci, HCI_SUCCESS); |
1820 | 1820 |
break; |
b/qemu-common.h | ||
---|---|---|
82 | 82 |
/* cutils.c */ |
83 | 83 |
void pstrcpy(char *buf, int buf_size, const char *str); |
84 | 84 |
char *pstrcat(char *buf, int buf_size, const char *s); |
85 |
char *pstrdup(const char *str, size_t buf_size); |
|
85 | 86 |
int strstart(const char *str, const char *val, const char **ptr); |
86 | 87 |
int stristart(const char *str, const char *val, const char **ptr); |
87 | 88 |
time_t mktimegm(struct tm *tm); |
Also available in: Unified diff