Zheng Zeng has uploaded this change for review.

View Change

SAL/nfs4_recovery.c: fix the issue where adding export fails when the gethostname function call fails

Assuming the value of "sysconf(_SC_HOST_NAME_MAX)" is len.

When the actual length of the hostname exceeds (len - 1), calling
the gethostname function will result in an error, which can cause
the operation of adding new export to fail.

This patch allocates 256 bytes of space by default to store the hostname.
If the length of the hostname exceeds len, it takes the first len characters.
Otherwise, it uses the hostname directly.

Change-Id: Idc2955e72a484db1d078ab4b6b2d070ab2857e89
Signed-off-by: izxl007 <zengzheng007@163.com>
---
M src/SAL/nfs4_recovery.c
1 file changed, 14 insertions(+), 6 deletions(-)

git pull ssh://review.gerrithub.io:29418/ffilz/nfs-ganesha refs/changes/06/1199506/1

To view, visit change 1199506. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: ffilz/nfs-ganesha
Gerrit-Branch: next
Gerrit-Change-Id: Idc2955e72a484db1d078ab4b6b2d070ab2857e89
Gerrit-Change-Number: 1199506
Gerrit-PatchSet: 1
Gerrit-Owner: Zheng Zeng <zengzheng007@163.com>