if duplicating strings, it’s idiotic to use strlcpy(3) when we know
the sizes (checked)
This commit is contained in:
parent
cfa64cebd1
commit
68f9bfa689
7
misc.c
7
misc.c
@ -29,7 +29,7 @@
|
||||
#include <grp.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.112 2009/07/25 21:31:26 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.113 2009/08/01 20:29:24 tg Exp $");
|
||||
|
||||
#undef USE_CHVT
|
||||
/* XXX conditions correct? */
|
||||
@ -1479,8 +1479,9 @@ strndup_(const char *src, size_t len, Area *ap)
|
||||
char *dst = NULL;
|
||||
|
||||
if (src != NULL) {
|
||||
dst = alloc(++len, ap);
|
||||
strlcpy(dst, src, len);
|
||||
dst = alloc(len + 1, ap);
|
||||
memcpy(dst, src, len);
|
||||
dst[len] = '\0';
|
||||
}
|
||||
return (dst);
|
||||
}
|
||||
|
16
sh.h
16
sh.h
@ -134,7 +134,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.319 2009/08/01 14:21:30 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.320 2009/08/01 20:29:25 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R39 2009/08/01"
|
||||
|
||||
@ -422,9 +422,10 @@ char *ucstrstr(char *, const char *);
|
||||
char *strdup_dst = NULL; \
|
||||
\
|
||||
if (strdup_src != NULL) { \
|
||||
size_t strdup_len = strlen(strdup_src) + 1; \
|
||||
strdup_dst = alloc(strdup_len, (ap)); \
|
||||
strlcpy(strdup_dst, strdup_src, strdup_len); \
|
||||
size_t strdup_len = strlen(strdup_src); \
|
||||
strdup_dst = alloc(strdup_len + 1, (ap)); \
|
||||
memcpy(strdup_dst, strdup_src, strdup_len); \
|
||||
strdup_dst[strdup_len] = '\0'; \
|
||||
} \
|
||||
(d) = strdup_dst; \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
@ -433,9 +434,10 @@ char *ucstrstr(char *, const char *);
|
||||
char *strdup_dst = NULL; \
|
||||
\
|
||||
if (strdup_src != NULL) { \
|
||||
size_t strdup_len = (n) + 1; \
|
||||
strdup_dst = alloc(strdup_len, (ap)); \
|
||||
strlcpy(strdup_dst, strdup_src, strdup_len); \
|
||||
size_t strdup_len = (n); \
|
||||
strdup_dst = alloc(strdup_len + 1, (ap)); \
|
||||
memcpy(strdup_dst, strdup_src, strdup_len); \
|
||||
strdup_dst[strdup_len] = '\0'; \
|
||||
} \
|
||||
(d) = strdup_dst; \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
|
Loading…
Reference in New Issue
Block a user