/* This file is part of limb https://lila.oss/limb
* Copyright (C) 2023 Olivier Brunel jjk@jjacky.com */
/* SPDX-License-Identifier: GPL-2.0-only */
#include <limb/djbunix.h>
int
sa_readlinkat0(stralloc *sa, int fd, const char * restrict file)
{
int r = sa_readlinkat(sa, fd, file);
if (r < 0)
return r;
/* make sure it ends with a NUL - which isn't guaranteed */
if (sa->s[sa->len - 1] != 0 && !stralloc_0(sa))
return -1;
return 0;
}