suitable.
ok jsg
rlen = dlen + (needslash ? 1 : 0) + flen;
ret = domalloc(rlen + 1);
- strcpy(ret, dir);
- if (needslash) {
- strcat(ret, "/");
- }
- strcat(ret, file);
+ snprintf(ret, rlen+1, "%s%s%s", dir, needslash ? "/" : "", file);
return ret;
}
for (i=0; i<num; i++) {
ei = expansionitemarray_get(&es->curmacro->expansion, i);
if (ei->isstring) {
- strcat(ret, ei->string);
+ strlcat(ret, ei->string, len+1);
} else {
arg = stringarray_get(&es->args, ei->param);
- strcat(ret, arg);
+ strlcat(ret, arg, len+1);
}
}
#include <stdlib.h>
#include <string.h>
+#include <stdio.h>
#include <assert.h>
#include "utils.h"
len = strlen(s);
ret = domalloc(len+1);
- strcpy(ret, s);
+ strlcpy(ret, s, len+1);
return ret;
}
len = strlen(s) + strlen(t);
ret = domalloc(len+1);
- strcpy(ret, s);
- strcat(ret, t);
+ snprintf(ret, len+1, "%s%s", s, t);
return ret;
}
len = strlen(s) + strlen(t) + strlen(u);
ret = domalloc(len+1);
- strcpy(ret, s);
- strcat(ret, t);
- strcat(ret, u);
+ snprintf(ret, len+1, "%s%s%s", s, t, u);
return ret;
}