diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-06-18 20:03:57 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-06-18 20:11:16 -0700 |
commit | 83db3bbee4e19e7426a32ee89ad6c2d8e48260f2 (patch) | |
tree | a6fb6f6b6acaa09d5a43cd669f87c2f7f519a521 /src/map/itemdb.cpp | |
parent | 8b5370313dcc00a45ea5c3e8b4c497bc00fd8e13 (diff) | |
download | tmwa-83db3bbee4e19e7426a32ee89ad6c2d8e48260f2.tar.gz tmwa-83db3bbee4e19e7426a32ee89ad6c2d8e48260f2.tar.bz2 tmwa-83db3bbee4e19e7426a32ee89ad6c2d8e48260f2.tar.xz tmwa-83db3bbee4e19e7426a32ee89ad6c2d8e48260f2.zip |
Also poison memcpy, memmove, and memset
Diffstat (limited to 'src/map/itemdb.cpp')
-rw-r--r-- | src/map/itemdb.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp index 147db91..329bab8 100644 --- a/src/map/itemdb.cpp +++ b/src/map/itemdb.cpp @@ -161,7 +161,6 @@ int itemdb_readdb(void) char line[1024]; int ln = 0, lines = 0; int nameid, j; - char *str[32], *p, *np; struct item_data *id; int i = 0; const char *filename[] = { "db/item_db.txt", "db/item_db2.txt" }; @@ -184,7 +183,9 @@ int itemdb_readdb(void) lines++; if (line[0] == '/' && line[1] == '/') continue; - memset(str, 0, sizeof(str)); + char *str[32] {}; + char *p; + char *np; for (j = 0, np = p = line; j < 17 && p; j++) { while (*p == '\t' || *p == ' ') @@ -207,8 +208,8 @@ int itemdb_readdb(void) //ID,Name,Jname,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Gender,Loc,wLV,eLV,View id = itemdb_search(nameid); - memcpy(id->name, str[1], 24); - memcpy(id->jname, str[2], 24); + strzcpy(id->name, str[1], 24); + strzcpy(id->jname, str[2], 24); id->type = ItemType(atoi(str[3])); id->value_buy = atoi(str[4]); id->value_sell = atoi(str[5]); @@ -269,7 +270,6 @@ int itemdb_read_itemavail(void) char line[1024]; int ln = 0; int nameid, j, k; - char *str[10], *p; if ((fp = fopen_("db/item_avail.txt", "r")) == NULL) { @@ -282,7 +282,8 @@ int itemdb_read_itemavail(void) struct item_data *id; if (line[0] == '/' && line[1] == '/') continue; - memset(str, 0, sizeof(str)); + char *str[10] {}; + char *p; for (j = 0, p = line; j < 2 && p; j++) { str[j] = p; @@ -323,7 +324,6 @@ int itemdb_read_noequip(void) char line[1024]; int ln = 0; int nameid, j; - char *str[32], *p; struct item_data *id; if ((fp = fopen_("db/item_noequip.txt", "r")) == NULL) @@ -335,7 +335,8 @@ int itemdb_read_noequip(void) { if (line[0] == '/' && line[1] == '/') continue; - memset(str, 0, sizeof(str)); + char *str[32] {}; + char *p; for (j = 0, p = line; j < 2 && p; j++) { str[j] = p; |