< prev index next >

src/hotspot/share/services/attachListener.hpp

Print this page
rev 49172 : 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

*** 1,7 **** /* ! * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 122,132 **** // set the operation name void set_name(char* name) { size_t len = strlen(name); assert(len <= name_length_max, "exceeds maximum name length"); ! memcpy(_name, name, MIN2(len + 1, (size_t)name_length_max)); } // get an argument value const char* arg(int i) const { assert(i>=0 && i<arg_count_max, "invalid argument index"); --- 122,134 ---- // set the operation name void set_name(char* name) { size_t len = strlen(name); assert(len <= name_length_max, "exceeds maximum name length"); ! len = MIN2(len, (size_t)name_length_max); ! memcpy(_name, name, len); ! _name[len] = '\0'; } // get an argument value const char* arg(int i) const { assert(i>=0 && i<arg_count_max, "invalid argument index");
*** 139,149 **** if (arg == NULL) { _arg[i][0] = '\0'; } else { size_t len = strlen(arg); assert(len <= arg_length_max, "exceeds maximum argument length"); ! memcpy(_arg[i], arg, MIN2(len + 1, (size_t)arg_length_max)); } } // create an operation of a given name AttachOperation(char* name) { --- 141,153 ---- if (arg == NULL) { _arg[i][0] = '\0'; } else { size_t len = strlen(arg); assert(len <= arg_length_max, "exceeds maximum argument length"); ! len = MIN2(len, (size_t)arg_length_max); ! memcpy(_arg[i], arg, len); ! _arg[i][len] = '\0'; } } // create an operation of a given name AttachOperation(char* name) {
< prev index next >