Skip to content

Commit

Permalink
Fix NULL pointer dereference and remove three lines of dead code.
Browse files Browse the repository at this point in the history
QbitLogic has run [Code]Ai on the open-vm-tools source code and
and notified VMware of a potential NULL pointer reference and four
pieces of dead code.

See #247

bora-vmsoft/services/vmtoolsd/pluginMgr.c
The proposed fix conditionally emitted a log message.  That fix has
been reworked to consistently emit a log message with conditional
content.

bora/lib/misc/posixPosix.c
bora-vmsoft/apps/toolbox-cmd/toolboxcmd-shrink.c
Remove one line of dead code from each source file.

bora-vmsoft/lib/procMgr/procMgrPosix.c:
Suggested dead code fix actually pointed to a bug where errno
was not getting updated as intended.

bora-vmsoft/services/plugins/guestInfo/perfMonLinux.c:
Suggested dead code is no longer dead; change not applicable.
  • Loading branch information
oliverkurth committed Dec 18, 2018
1 parent bbcb8a4 commit f91f735
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 4 additions & 0 deletions open-vm-tools/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ John Eismeier Propose fix some spelling.

Josh Paetzel Additional changes to vmmemctl.ko for FreeBSD 12.0 API changes.
- https://github.com/vmware/open-vm-tools/pull/286

[Code]Ai Highlighted a potential NULL pointer dereference and four
pieces of dead code.
- https://github.com/vmware/open-vm-tools/pull/247
3 changes: 1 addition & 2 deletions open-vm-tools/lib/misc/posixPosix.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 2008-2017 VMware, Inc. All rights reserved.
* Copyright (C) 2008-2018 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
Expand Down Expand Up @@ -2111,7 +2111,6 @@ Posix_Getmntent_r(FILE *fp, // IN:
goto exit;
}
m->mnt_opts = memcpy(buf + n, opts, len);
n += len;
}
ret = 0;

Expand Down
4 changes: 2 additions & 2 deletions open-vm-tools/lib/procMgr/procMgrPosix.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 1998-2017 VMware, Inc. All rights reserved.
* Copyright (C) 1998-2018 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
Expand Down Expand Up @@ -2206,7 +2206,7 @@ ProcMgr_ImpersonateUserStart(const char *user, // IN: UTF-8 encoded user name
* according to POSIX 1003.1-2003, so patch up the errno.
*/
if (error == 0) {
error = ENOENT;
errno = ENOENT;
}
return FALSE;
}
Expand Down
3 changes: 2 additions & 1 deletion open-vm-tools/services/vmtoolsd/pluginMgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,8 @@ ToolsCore_UnloadPlugins(ToolsServiceState *state)
ToolsPlugin *plugin = g_ptr_array_index(state->plugins, state->plugins->len - 1);
GArray *regs = (plugin->data != NULL) ? plugin->data->regs : NULL;

g_message("Unloading plugin '%s'.\n", plugin->data->name);
g_message("Unloading plugin '%s'.\n",
plugin->data != NULL ? plugin->data->name : "unknown");

if (regs != NULL) {
guint i;
Expand Down
2 changes: 0 additions & 2 deletions open-vm-tools/toolbox/toolboxcmd-shrink.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,6 @@ ShrinkDoWipeAndShrink(char *mountPoint, // IN: mount point
} else {
ToolsCmd_PrintErr(SU_(error.message, "Error: %s\n"), err);
}

rc = EX_TEMPFAIL;
break;
}

Expand Down

0 comments on commit f91f735

Please sign in to comment.