134affccfd
based on diffs from new maintainer Jeremy Evans <jeremyevans0 at gmail.com>
59 lines
1.9 KiB
Plaintext
59 lines
1.9 KiB
Plaintext
$OpenBSD: patch-src_PropSet_cxx,v 1.2 2007/01/18 10:56:27 steven Exp $
|
|
--- src/PropSet.cxx.orig Tue Mar 28 17:31:51 2006
|
|
+++ src/PropSet.cxx Tue Mar 28 17:57:29 2006
|
|
@@ -78,14 +78,14 @@ bool EqualCaseInsensitive(const char *a,
|
|
|
|
SString::SString(int i) : sizeGrowth(sizeGrowthDefault) {
|
|
char number[32];
|
|
- sprintf(number, "%0d", i);
|
|
+ snprintf(number, sizeof(number), "%0d", i);
|
|
s = StringAllocate(number);
|
|
sSize = sLen = (s) ? strlen(s) : 0;
|
|
}
|
|
|
|
SString::SString(double d, int precision) : sizeGrowth(sizeGrowthDefault) {
|
|
char number[32];
|
|
- sprintf(number, "%.*f", precision, d);
|
|
+ snprintf(number, sizeof(number), "%.*f", precision, d);
|
|
s = StringAllocate(number);
|
|
sSize = sLen = (s) ? strlen(s) : 0;
|
|
}
|
|
@@ -635,9 +635,10 @@ SString PropSet::GetNewExpand(const char
|
|
val.clear(); // Self-references evaluate to empty string
|
|
size_t newlenbase = strlen(base) + val.length() - lenvar;
|
|
char *newbase = new char[newlenbase];
|
|
- strncpy(newbase, base, cpvar - base);
|
|
- strcpy(newbase + (cpvar - base), val.c_str());
|
|
- strcpy(newbase + (cpvar - base) + val.length(), cpendvar + 1);
|
|
+ *cpvar = 0;
|
|
+ strlcpy(newbase, base, newlenbase);
|
|
+ strlcat(newbase, val.c_str(), newlenbase);
|
|
+ strlcat(newbase, cpendvar + 1, newlenbase);
|
|
delete []var;
|
|
delete []base;
|
|
base = newbase;
|
|
@@ -679,18 +680,15 @@ char *PropSet::ToString() {
|
|
len = 1; // Return as empty string
|
|
char *ret = new char [len];
|
|
if (ret) {
|
|
- char *w = ret;
|
|
+ ret[0] = 0;
|
|
for (int root = 0; root < hashRoots; root++) {
|
|
for (Property *p = props[root]; p; p = p->next) {
|
|
- strcpy(w, p->key);
|
|
- w += strlen(p->key);
|
|
- *w++ = '=';
|
|
- strcpy(w, p->val);
|
|
- w += strlen(p->val);
|
|
- *w++ = '\n';
|
|
+ strlcat(ret, p->key, len);
|
|
+ strlcat(ret, "=", len);
|
|
+ strlcat(ret, p->val, len);
|
|
+ strlcat(ret, "\n", len);
|
|
}
|
|
}
|
|
- ret[len-1] = '\0';
|
|
}
|
|
return ret;
|
|
}
|