#include "defines.h"
#include "prototypes.h"
+#include "fs/readlink/readlinknul.h"
#include "getdef.h"
#include "shadowio.h"
#include "tcbfuncs.h"
-
#include "shadowlog_internal.h"
+
#define SHADOWTCB_HASH_BY 1000
#define SHADOWTCB_LOCK_SUFFIX ".lock"
char *path, *rval;
struct stat st;
char link[8192];
- ssize_t ret;
if (asprintf (&path, TCB_DIR "/%s", name) == -1) {
OUT_OF_MEMORY;
free (path);
return NULL;
}
- ret = readlink (path, link, sizeof (link) - 1);
- if (-1 == ret) {
+ if (READLINKNUL(path, link) == -1) {
fprintf (shadow_logfd,
_("%s: Cannot read symbolic link %s: %s\n"),
shadow_progname, path, strerror (errno));
return NULL;
}
free (path);
- if ((size_t)ret >= sizeof(link) - 1) {
- stpcpy(&link[sizeof(link) - 1], "");
- fprintf (shadow_logfd,
- _("%s: Suspiciously long symlink: %s\n"),
- shadow_progname, link);
- return NULL;
- }
- stpcpy(&link[ret], "");
rval = strdup (link);
if (NULL == rval) {
OUT_OF_MEMORY;
#include "atoi/getnum.h"
#include "defines.h"
+#include "fs/readlink/readlinknul.h"
#include "prototypes.h"
#ifdef ENABLE_SUBIDS
#include "subordinateio.h"
/* 41: /proc/xxxxxxxxxx/task/xxxxxxxxxx/ns/user + \0 */
char path[41];
char buf[512], buf2[512];
- ssize_t llen1, llen2;
SNPRINTF(path, "/proc/%s/ns/user", sname);
- if ((llen1 = readlink (path, buf, sizeof(buf))) == -1)
+ if (READLINKNUL(path, buf) == -1)
return 0;
- if ((llen2 = readlink ("/proc/self/ns/user", buf2, sizeof(buf2))) == -1)
+ if (READLINKNUL("/proc/self/ns/user", buf2) == -1)
return 0;
- if (llen1 == llen2 && memcmp (buf, buf2, llen1) == 0)
+ if (strcmp(buf, buf2) == 0)
return 0; /* same namespace */
return 1;