diff --git a/open-vm-tools/lib/appUtil/appUtilX11.c b/open-vm-tools/lib/appUtil/appUtilX11.c index 1e2c94031..c08ead8f6 100644 --- a/open-vm-tools/lib/appUtil/appUtilX11.c +++ b/open-vm-tools/lib/appUtil/appUtilX11.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2019,2022 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -174,6 +174,9 @@ AppUtilCollectNamedIcons(GPtrArray *pixbufs, // IN/OUT */ iconSearchNameSize = strlen(iconName) + 1; iconSearchName = g_alloca(iconSearchNameSize); + + /* Ignore return, returns length of the source string */ + /* coverity[check_return] */ g_strlcpy(iconSearchName, iconName, iconSearchNameSize); myIconName = NULL; @@ -769,7 +772,7 @@ AppUtil_AppIsSkippable(const char *appName) * Path, or NULL if not available * * Side effects: - * Allocated memory is returned + * Allocated memory is returned * *----------------------------------------------------------------------------- */ diff --git a/open-vm-tools/lib/globalConfig/globalConfig.c b/open-vm-tools/lib/globalConfig/globalConfig.c index f1b3f9345..ec92300b4 100644 --- a/open-vm-tools/lib/globalConfig/globalConfig.c +++ b/open-vm-tools/lib/globalConfig/globalConfig.c @@ -563,6 +563,9 @@ LoadConfigFile(const gchar *confPath, } cfg = g_key_file_new(); + + /* On error, 'err' will be set, null otherwise. */ + /* coverity[check_return] */ g_key_file_load_from_file(cfg, confPath, G_KEY_FILE_NONE, &err); if (err != NULL) { diff --git a/open-vm-tools/lib/hgfs/cpName.c b/open-vm-tools/lib/hgfs/cpName.c index 00d90ce2c..3be533365 100644 --- a/open-vm-tools/lib/hgfs/cpName.c +++ b/open-vm-tools/lib/hgfs/cpName.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2016 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2016,2022 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -168,7 +168,14 @@ CPNameEscapeAndConvertFrom(char const **bufIn, // IN/OUT: Input to convert } /* Leaving space for the leading path separator, thus output to savedBufOut + 1. */ - *inSize = HgfsEscape_Do(*bufIn, *inSize, savedOutSize, savedBufOut + 1); + result = HgfsEscape_Do(*bufIn, *inSize, savedOutSize - 1, savedBufOut + 1); + if (result < 0) { + Log("%s: error: not enough room to perform escape: %d\n", + __FUNCTION__, result); + return -1; + } + *inSize = (size_t) result; + result = CPNameConvertFrom(&savedOutConst, inSize, outSize, bufOut, pathSep); *bufIn += *inSize; *inSize = 0; @@ -221,10 +228,10 @@ CPNameConvertFrom(char const **bufIn, // IN/OUT: Input to convert ASSERT(bufOut); in = *bufIn; + inEnd = in + *inSize; if (inPlaceConvertion) { in++; // Skip place for the leading path separator. } - inEnd = in + *inSize; myOutSize = *outSize; out = *bufOut; diff --git a/open-vm-tools/lib/hgfs/hgfsEscape.c b/open-vm-tools/lib/hgfs/hgfsEscape.c index 7921b08bc..f1d482204 100644 --- a/open-vm-tools/lib/hgfs/hgfsEscape.c +++ b/open-vm-tools/lib/hgfs/hgfsEscape.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2019,2022 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -842,7 +842,6 @@ HgfsEscape_Undo(char *bufIn, // IN: Characters to be unescaped result += componentSize; if (unprocessedSize > 1) { currentComponent = currentComponent + componentSize; - componentSize = strlen(currentComponent) + 1; // Size of the next component } else { currentComponent = NULL; } diff --git a/open-vm-tools/libvmtools/vmtoolsConfig.c b/open-vm-tools/libvmtools/vmtoolsConfig.c index 89d37e8b0..404399b51 100644 --- a/open-vm-tools/libvmtools/vmtoolsConfig.c +++ b/open-vm-tools/libvmtools/vmtoolsConfig.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2008-2022 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -150,6 +150,8 @@ VMTools_LoadConfig(const gchar *path, goto exit; } + /* On error, 'err' will be set, null otherwise */ + /* coverity[check_return] */ g_key_file_load_from_file(cfg, localPath, flags, &err); if (err == NULL || err->code == G_KEY_FILE_ERROR_GROUP_NOT_FOUND) { goto exit; diff --git a/open-vm-tools/namespacetool/namespacetool.c b/open-vm-tools/namespacetool/namespacetool.c index 482f02ab3..0728f9b38 100644 --- a/open-vm-tools/namespacetool/namespacetool.c +++ b/open-vm-tools/namespacetool/namespacetool.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2016-2020 VMware, Inc. All rights reserved. + * Copyright (C) 2016-2020,2022 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -279,7 +279,7 @@ GetValueFromFile(const char *filePath, char **fileContents, gsize *length) *fileContents = NULL; *length = 0; } - g_free(gErr); + g_error_free(gErr); return retVal; } diff --git a/open-vm-tools/vgauth/common/certverify.c b/open-vm-tools/vgauth/common/certverify.c index e54c936b6..f742597c8 100644 --- a/open-vm-tools/vgauth/common/certverify.c +++ b/open-vm-tools/vgauth/common/certverify.c @@ -162,6 +162,8 @@ VerifyCallback(int ok, X509_NAME_oneline(X509_get_subject_name(curCert), nameBuf, sizeof(nameBuf) - 1); nameBuf[sizeof(nameBuf)-1] = '\0'; } else { + /* Ignore return, returns length of the source string */ + /* coverity[check_return] */ g_strlcpy(nameBuf, "", sizeof nameBuf); } g_debug("%s: name: %s ok: %d error '%s' (%d) at %d depth lookup:%s\n", diff --git a/open-vm-tools/vgauth/lib/netPosix.c b/open-vm-tools/vgauth/lib/netPosix.c index 0deac8ac6..706df599c 100644 --- a/open-vm-tools/vgauth/lib/netPosix.c +++ b/open-vm-tools/vgauth/lib/netPosix.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2011-2016,2019 VMware, Inc. All rights reserved. + * Copyright (C) 2011-2016,2019,2022 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -74,6 +74,8 @@ VGAuth_NetworkConnect(VGAuthContext *ctx) return VGAUTH_E_COMM; } + /* Ignore return, returns the length of the source string */ + /* coverity[check_return] */ g_strlcpy(sockaddr.sun_path, ctx->comm.pipeName, UNIX_PATH_MAX); do { diff --git a/open-vm-tools/vgauth/serviceImpl/netPosix.c b/open-vm-tools/vgauth/serviceImpl/netPosix.c index 3658fb100..7d45baf9b 100644 --- a/open-vm-tools/vgauth/serviceImpl/netPosix.c +++ b/open-vm-tools/vgauth/serviceImpl/netPosix.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2011-2017, 2019-2021 VMware, Inc. All rights reserved. + * Copyright (C) 2011-2017, 2019-2022 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -151,8 +151,14 @@ ServiceNetworkListen(ServiceConnection *conn, // IN/OUT sockaddr.sun_family = PF_UNIX; - g_unlink(conn->pipeName); + ret = g_unlink(conn->pipeName); + if (ret < 0 && errno != ENOENT) { + Warning("%s: unlink(%s) failed, %d - continuing\n", __FUNCTION__, + conn->pipeName, errno); + } + /* Ignore return, returns the length of the source string */ + /* coverity[check_return] */ g_strlcpy(sockaddr.sun_path, conn->pipeName, UNIX_PATH_MAX); ret = bind(sock, (struct sockaddr *) &sockaddr, sizeof sockaddr); @@ -304,6 +310,7 @@ ServiceNetworkCloseConnection(ServiceConnection *conn) void ServiceNetworkRemoveListenPipe(ServiceConnection *conn) { + /* coverity[check_return] */ ServiceFileUnlinkFile(conn->pipeName); }