vpdupdate: Fixes syntax error bug on LE From: Janani [root@ltcbrazos2-lp12 home]# vpdupdate sh: -c: line 1: syntax error: unexpected end of file Some junk characters get introduced as parameters in the iprconfig command line. This causes the unexpected end of file error. We clear out the string before assigning it, in order to clear the junk. Signed-off-by: Janani Venkataraman --- src/helper_functions.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/helper_functions.cpp b/src/helper_functions.cpp index a9524f7..a46119d 100644 --- a/src/helper_functions.cpp +++ b/src/helper_functions.cpp @@ -28,9 +28,10 @@ #include #include #include +#include -#define BUF_SIZE 512 +#define BUF_SIZE PATH_MAX using namespace std; using namespace lsvpd; @@ -156,12 +157,13 @@ string HelperFunctions::parseString(const string& line, int str_pos, string& out */ string HelperFunctions::getSymLinkTarget(const string& symLinkPath) { - char linkTarget[BUF_SIZE], *buf; - + char linkTarget[BUF_SIZE], *buf = NULL; + memset (linkTarget, 0, BUF_SIZE); + buf = strdup(symLinkPath.c_str()); - int len = readlink(buf, linkTarget, sizeof( - linkTarget)); - linkTarget[len] = '\0'; + if (buf != NULL) + readlink(buf, linkTarget, BUF_SIZE - 1); + return string(getAbsolutePath(linkTarget, buf)); }