misc-progs: Remove own copy of strlcat.

Add compatibility define that uses strncat.
This commit is contained in:
Michael Tremer
2013-10-12 18:23:40 +02:00
parent 52e54c1c9a
commit 2b875b3985
2 changed files with 4 additions and 22 deletions

View File

@@ -115,27 +115,6 @@ int system_core(char* command, uid_t uid, gid_t gid, char *error)
}
/* BSD style safe strcat; from the secure programming cookbook */
size_t strlcat(char *dst, const char *src, size_t len) {
char *dstptr = dst;
size_t dstlen, tocopy = len;
const char *srcptr = src;
while (tocopy-- && *dstptr) dstptr++;
dstlen = dstptr - dst;
if (!(tocopy = len - dstlen)) return (dstlen + strlen(src));
while (*srcptr) {
if (tocopy != 1) {
*dstptr++ = *srcptr;
tocopy--;
}
srcptr++;
}
*dstptr = 0;
return (dstlen + (srcptr - src));
}
/* General routine to initialise a setuid root program, and put the
* environment in a known state. Returns 1 on success, if initsetuid() returns
* 0 then you should exit(1) immediately, DON'T attempt to recover from the

View File

@@ -23,7 +23,10 @@ extern char * trusted_env[4];
int system_core(char* command, uid_t uid, gid_t gid, char *error);
int safe_system(char* command);
int unpriv_system(char* command, uid_t uid, gid_t gid);
size_t strlcat(char *dst, const char *src, size_t len);
int initsetuid(void);
/* Compatibility for the local copy of strlcat,
* which has been removed. */
#define strlcat(src, dst, size) strncat(src, dst, size)
#endif