/* Remove size modifiers - "%Ld" would try to printf
* long long, we pass long, and it spews garbage */
if ((*f | 0x20) == 'l' || *f == 'h' || *f == 'z') {
- strcpy(f, f + 1);
+ overlapping_strcpy(f, f + 1);
}
//FIXME: actually, the same happens with bare "%d":
//it printfs an int, but we pass long!
slashes++;
/* Odd number of preceding slashes - newline is escaped */
if (slashes & 1) {
- strcpy(eol-1, eol);
+ overlapping_strcpy(eol - 1, eol);
eol = strchr(eol, '\n');
goto next;
}
char *xstrdup(const char *s) FAST_FUNC;
char *xstrndup(const char *s, int n) FAST_FUNC;
+void overlapping_strcpy(char *dst, const char *src) FAST_FUNC;
char *safe_strncpy(char *dst, const char *src, size_t size) FAST_FUNC;
/* Guaranteed to NOT be a macro (smallest code). Saves nearly 2k on uclibc.
* But potentially slow, don't use in one-billion-times loops */
vi_case(CTRL('U')|vbit:)
/* Control-U -- Clear line before cursor */
if (cursor) {
- strcpy(command, command + cursor);
+ overlapping_strcpy(command, command + cursor);
command_len -= cursor;
redraw(cmdedit_y, command_len);
}
int n = strspn(line, delims);
if (n) {
ii -= n;
- strcpy(line, line + n);
+ overlapping_strcpy(line, line + n);
}
// cut trailing
if (ii) {
dst[--size] = '\0';
return strncpy(dst, src, size);
}
+
+/* Like strcpy but can copy overlapping strings. */
+void FAST_FUNC overlapping_strcpy(char *dst, const char *src)
+{
+ while ((*dst = *src) != '\0') {
+ dst++;
+ src++;
+ }
+}
if (!cur)
break;
if (cur[1] == '%') { // %%
- strcpy(cur, cur+1);
+ overlapping_strcpy(cur, cur + 1);
cur++;
goto again;
}