Skip to content

Commit

Permalink
Remove tail before display whole entry in xhost
Browse files Browse the repository at this point in the history
  • Loading branch information
kala13x committed Mar 6, 2025
1 parent c4b53a1 commit 03839cc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tools/xhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define XHOST_FILE_PATH "/etc/hosts"
#define XHOST_VERSION_MAX 1
#define XHOST_VERSION_MIN 0
#define XHOST_BUILD_NUMBER 6
#define XHOST_BUILD_NUMBER 7

typedef struct {
xbool_t bAdd;
Expand Down Expand Up @@ -557,10 +557,14 @@ static int XHost_DisplayHosts(xhost_ctx_t *pCtx, xbool_t bLines)
}
}

if (pCtx->hosts.nLength)
if (pCtx->hosts.nLength && pCtx->hosts.pData)
{
char *pData = (char*)pCtx->hosts.pData;
size_t nLength = pCtx->hosts.nLength;
XHost_RemoveTailSpace(pData, nLength);

xlog_useheap(XTRUE);
xlog("%s", pCtx->hosts.pData);
xlog("%s", pData);
}

return XSTDNON;
Expand Down

0 comments on commit 03839cc

Please sign in to comment.