mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +02:00
misc-progs: Remove own copy of strlcat.
Add compatibility define that uses strncat.
This commit is contained in:
@@ -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
|
/* General routine to initialise a setuid root program, and put the
|
||||||
* environment in a known state. Returns 1 on success, if initsetuid() returns
|
* 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
|
* 0 then you should exit(1) immediately, DON'T attempt to recover from the
|
||||||
|
|||||||
@@ -23,7 +23,10 @@ extern char * trusted_env[4];
|
|||||||
int system_core(char* command, uid_t uid, gid_t gid, char *error);
|
int system_core(char* command, uid_t uid, gid_t gid, char *error);
|
||||||
int safe_system(char* command);
|
int safe_system(char* command);
|
||||||
int unpriv_system(char* command, uid_t uid, gid_t gid);
|
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);
|
int initsetuid(void);
|
||||||
|
|
||||||
|
/* Compatibility for the local copy of strlcat,
|
||||||
|
* which has been removed. */
|
||||||
|
#define strlcat(src, dst, size) strncat(src, dst, size)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user