output stringlengths 64 73.2k | input stringlengths 208 73.3k | instruction stringclasses 1
value |
|---|---|---|
#fixed code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator indica... | #vulnerable code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public SolutionSet execute() throws JMException, ClassNotFoundException {
initParams();
success_ = false;
// Step 1 Create the initial population and evaluate
for (int i = 0; i < swarmSize_; i++) {
Solution particle = new Solution(problem_);
proble... | #vulnerable code
public SolutionSet execute() throws JMException, ClassNotFoundException {
initParams();
success_ = false;
globalBest_ = null ;
//->Step 1 (and 3) Create the initial population and evaluate
for (int i = 0; i < swarmSize_; i++) {
Solution particl... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator indica... | #vulnerable code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void loadInstance() throws IOException {
File archivo = new File(fileName_);
FileReader fr = null;
BufferedReader br = null;
fr = new FileReader(archivo);
br = new BufferedReader(fr);
// File reading
String line;
int lineCnt = 0;
line... | #vulnerable code
public void loadInstance() {
try {
File archivo = new File(fileName_);
FileReader fr = null;
BufferedReader br = null;
fr = new FileReader(archivo);
br = new BufferedReader(fr);
// File reading
String line;
int lineCnt ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator indica... | #vulnerable code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void run() {
neighborhood_ = parentThread_.neighborhood_;
problem_ = parentThread_.problem_;
lambda_ = parentThread_.lambda_;
population_ = parentThread_.population_;
z_ = parentThread_.z_;
indArray_ = parentThread_.indArray_;
barrier_ = paren... | #vulnerable code
public void run() {
neighborhood_ = parentThread_.neighborhood_;
problem_ = parentThread_.problem_;
lambda_ = parentThread_.lambda_;
population_ = parentThread_.population_;
z_ = parentThread_.z_;
indArray_ = parentThread_.indArray_;
barrier_ =... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator indica... | #vulnerable code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
static public void loadColumnVectorFromFile(String file, int rows, double[] column)
throws JMetalException {
try {
BufferedReader brSrc =
new BufferedReader(
new InputStreamReader(new FileInputStream(ClassLoader.getSystemResourc... | #vulnerable code
static public void loadColumnVectorFromFile(String file, int rows, double[] column)
throws JMetalException {
try {
BufferedReader brSrc = new BufferedReader(new FileReader(file));
loadColumnVector(brSrc, rows, column);
brSrc.close();
} catch ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testConfigure2() throws Exception {
double epsilon = 0.000000000000001 ;
Settings smsemoaSettings = new SMSEMOASettings("Fonseca");
SMSEMOA algorithm = (SMSEMOA) smsemoaSettings.configure(configuration) ;
Problem problem = new Fonseca("Real")... | #vulnerable code
@Test
public void testConfigure2() throws Exception {
double epsilon = 0.000000000000001 ;
Settings smsemoaSettings = new SMSEMOASettings("Fonseca");
Algorithm algorithm = smsemoaSettings.configure(configuration_) ;
Problem problem = new Fonseca("Real") ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testConfigure() throws Exception {
double epsilon = 0.000000000000001 ;
Settings nsgaIISettings = new NSGAIIBinarySettings("ZDT5");
NSGAII algorithm = (NSGAII)nsgaIISettings.configure() ;
Problem problem = new ZDT5("Binary") ;
SinglePoin... | #vulnerable code
@Test
public void testConfigure() throws Exception {
double epsilon = 0.000000000000001 ;
Settings nsgaIISettings = new NSGAIIBinarySettings("ZDT5");
Algorithm algorithm = nsgaIISettings.configure() ;
Problem problem = new ZDT5("Binary") ;
SinglePoi... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator indicat... | #vulnerable code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator i... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
static public void loadMatrixFromFile(String file, int rows, int columns, double[][] matrix)
throws JMetalException {
try {
BufferedReader brSrc =
new BufferedReader(
new InputStreamReader(new FileInputStream(ClassLoader.getSyst... | #vulnerable code
static public void loadMatrixFromFile(String file, int rows, int columns, double[][] matrix)
throws JMetalException {
try {
BufferedReader brSrc = new BufferedReader(new FileReader(file));
loadMatrix(brSrc, rows, columns, matrix);
brSrc.close();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testConfigure2() throws Exception {
double epsilon = 0.000000000000001 ;
Settings fastSMEEMOASettings = new FastSMSEMOASettings("Fonseca");
FastSMSEMOA algorithm = (FastSMSEMOA) fastSMEEMOASettings.configure(configuration) ;
Problem problem =... | #vulnerable code
@Test
public void testConfigure2() throws Exception {
double epsilon = 0.000000000000001 ;
Settings smsemoaSettings = new FastSMSEMOASettings("Fonseca");
Algorithm algorithm = smsemoaSettings.configure(configuration_) ;
Problem problem = new Fonseca("Rea... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void test() throws JMException {
double epsilon = 0.000000000000001;
GDE3_Settings GDE3Settings = new GDE3_Settings("Fonseca");
GDE3 algorithm = (GDE3) GDE3Settings.configure();
DifferentialEvolutionCrossover crossover =
(DifferentialEvolut... | #vulnerable code
@Test
public void test() throws JMException {
double epsilon = 0.000000000000001;
Settings GDE3Settings = new GDE3_Settings("Fonseca");
Algorithm algorithm = GDE3Settings.configure();
//Problem problem = new Fonseca("Real");
DifferentialEvolutionCro... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testConfigure2() throws Exception {
double epsilon = 0.000000000000001 ;
Settings nsgaIISettings = new NSGAIIBinarySettings("ZDT5");
NSGAII algorithm = (NSGAII)nsgaIISettings.configure(configuration_) ;
Problem problem = new ZDT5("Binary") ;
... | #vulnerable code
@Test
public void testConfigure2() throws Exception {
double epsilon = 0.000000000000001 ;
Settings nsgaIISettings = new NSGAIIBinarySettings("ZDT5");
Algorithm algorithm = nsgaIISettings.configure(configuration_) ;
Problem problem = new ZDT5("Binary") ;... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator indica... | #vulnerable code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public int compare(Solution solution1, Solution solution2) {
if (solution1 == null) {
return 1;
} else if (solution2 == null) {
return -1;
}
if (NSGAIIAttr.getAttributes(solution1).getRank() < NSGAIIAttr.getAttributes(solution2).getRank(... | #vulnerable code
@Override
public int compare(Solution solution1, Solution solution2) {
if (solution1 == null) {
return 1;
} else if (solution2 == null) {
return -1;
}
if ((int)solution1.getAlgorithmAttributes().getAttribute("Rank") < (int)solution2.getAlgor... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
static public void loadNMatrixFromFile(String file, int N, int rows, int columns,
double[][][] matrix) throws JMetalException {
try {
BufferedReader brSrc =
new BufferedReader(
new InputStreamReader(new FileInputStream(ClassLoad... | #vulnerable code
static public void loadNMatrixFromFile(String file, int N, int rows, int columns,
double[][][] matrix) throws JMetalException {
try {
BufferedReader brSrc = new BufferedReader(new FileReader(file));
for (int i = 0; i < N; i++) {
loadMatrix(brSr... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator indicat... | #vulnerable code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator i... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testConfigure() throws Exception {
double epsilon = 0.000000000000001 ;
Settings fastSMEEMOASettings = new FastSMSEMOASettings("Fonseca");
FastSMSEMOA algorithm = (FastSMSEMOA) fastSMEEMOASettings.configure() ;
Problem problem = new Fonseca("... | #vulnerable code
@Test
public void testConfigure() throws Exception {
double epsilon = 0.000000000000001 ;
Settings smsemoaSettings = new FastSMSEMOASettings("Fonseca");
Algorithm algorithm = smsemoaSettings.configure() ;
Problem problem = new Fonseca("Real") ;
SBXCr... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void test2() throws JMException {
double epsilon = 0.000000000000001;
Settings GDE3Settings = new GDE3_Settings("Fonseca");
GDE3 algorithm = (GDE3) GDE3Settings.configure(configuration_);
DifferentialEvolutionCrossover crossover =
(Differen... | #vulnerable code
@Test
public void test2() throws JMException {
double epsilon = 0.000000000000001;
Settings GDE3Settings = new GDE3_Settings("Fonseca");
Algorithm algorithm = GDE3Settings.configure(configuration_);
//Problem problem = new Fonseca("Real");
Different... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndicator in... | #vulnerable code
public static void main(String[] args) throws
JMException,
SecurityException,
IOException,
ClassNotFoundException {
Problem problem;
Algorithm algorithm;
Operator crossover;
Operator mutation;
Operator selection;
QualityIndica... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws JMetalException, IOException {
ExperimentData experimentData = new ExperimentData.Builder("Experiment2")
.algorithmNameList(new String[]{"NSGAII", "SMPSO", "MOCell"})
.problemList(new String[]{"ZDT1", "ZDT2", "ZDT3",... | #vulnerable code
public static void main(String[] args) throws JMetalException, IOException {
ExperimentData experimentData = new ExperimentData.Builder("Experiment2")
.algorithmNameList(new String[]{"NSGAII", "SMPSO", "MOCell"})
.problemList(new String[]{"ZDT1", "ZDT2", "... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
static public void loadRowVectorFromFile(String file, int columns, double[] row)
throws JMetalException {
try {
BufferedReader brSrc =
new BufferedReader(
new InputStreamReader(new FileInputStream(ClassLoader.getSystemResource(f... | #vulnerable code
static public void loadRowVectorFromFile(String file, int columns, double[] row)
throws JMetalException {
try {
BufferedReader brSrc = new BufferedReader(new FileReader(file));
loadRowVector(brSrc, columns, row);
brSrc.close();
} catch (Excep... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void initIdealPoint() throws JMException, ClassNotFoundException {
for (int i = 0; i < problem_.getNumberOfObjectives(); i++) {
z_[i] = 1.0e+30;
indArray_[i] = new Solution(problem_);
problem_.evaluate(indArray_[i]);
evaluations_++;
} // for
for (int i = 0; i ... | #vulnerable code
void updateOfSolutions(Solution indiv, int id, int type) {
// indiv: child solution
// id: the id of current subproblem
// type: update solutions in - neighborhood (1) or whole population (otherwise)
int size;
int time;
time = 0;
if (type == 1) {
size ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static LoggedInStatus webappLogin(HttpServletRequest request, HttpServletResponse response, boolean requiresAdminRights) throws IOException
{
// check if there a session and a login information attached to it
//HttpSession session = request.getSession(true);
//Logg... | #vulnerable code
public static LoggedInStatus webappLogin(HttpServletRequest request, HttpServletResponse response, boolean requiresAdminRights) throws IOException
{
// check if there a session and a login information attached to it
HttpSession session = request.getSession(true);
Lo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void printLine(SearchResult result){
StringBuilder builder = new StringBuilder();
HashMap<String, Object> extraFields = result.getExtraData();
for (String tag : tagsOrder) {
Object temp1 = extraFields.get(tag);
final String s = (temp1 != null) ?
te... | #vulnerable code
private void printLine(SearchResult result){
StringBuilder builder = new StringBuilder();
HashMap<String, Object> extraFields = result.getExtraData();
for (String tag : tagsOrder) {
Object temp1 = extraFields.get(tag);
String temp1String = temp1.toString(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void printLine(SearchResult result){
StringBuilder builder = new StringBuilder();
HashMap<String, Object> extraFields = result.getExtraData();
for (String tag : tagsOrder) {
Object temp1 = extraFields.get(tag);
String s = (temp1 != null) ? StringUtils.tr... | #vulnerable code
private void printLine(SearchResult result){
StringBuilder builder = new StringBuilder();
HashMap<String, Object> extraFields = result.getExtraData();
for (String tag : tagsOrder) {
Object temp1 = extraFields.get(tag);
String s = StringUtils.trimToEmpty(te... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void doGetExportCvs(HttpServletRequest req, HttpServletResponse resp) throws IOException{
resp.setHeader("Content-disposition","attachment; filename=QueryResultsExport.csv");
String queryString = req.getParameter("query");
String[] fields = req.getParameterValues("... | #vulnerable code
private void doGetExportCvs(HttpServletRequest req, HttpServletResponse resp) throws IOException{
resp.setHeader("Content-disposition","attachment; filename=QueryResultsExport.csv");
String queryString = req.getParameter("query");
String[] fields = req.getParameterVa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void printFile(byte[] bytes) throws IOException {
if (encrypt) {
byte[] encryptedBytes = new byte[0];
try {
cipher.init(Cipher.ENCRYPT_MODE, key);
encryptedBytes = cipher.doFinal(bytes);
} ca... | #vulnerable code
public void printFile(byte[] bytes) throws Exception {
InputStream in;
if(encrypt){
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] encryptedBytes = cipher.doFinal(bytes);
in = new ByteArrayInputStream(encryptedBytes);... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String token = req.getHeader("Authorization");
User user = Authentication.getInstance().getUsername(token);
if(user == null) {
resp.sendError(40... | #vulnerable code
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
//resp.addHeader("Access-Control-Allow-Origin", "*");
HttpSession session = req.getSession(false);
LoggedIn mLoggedIn = Session.getUse... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public JSONResource json(URI anUri) throws IOException {
return doGET(anUri, new JSONResource());
} | #vulnerable code
public JSONResource json(URI anUri) throws IOException, MalformedURLException {
JSONObject json = JSONObject.class.cast(anUri.toURL().openConnection().getContent());
return new JSONResource(json);
}
#location 2
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public JSONResource json(URI anUri) throws IOException {
return doGET(anUri, new JSONResource());
} | #vulnerable code
public JSONResource json(URI anUri) throws IOException, MalformedURLException {
JSONObject json = JSONObject.class.cast(anUri.toURL().openConnection().getContent());
return new JSONResource(json);
}
#location 2
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public HWDiskStore[] getDisks() {
List<HWDiskStore> result;
result = new ArrayList<>();
readMap.clear();
writeMap.clear();
populateReadWriteMaps();
Map<String, List<Object>> vals = WmiUtil.selectObjectsFrom(null, ... | #vulnerable code
@Override
public HWDiskStore[] getDisks() {
List<HWDiskStore> result;
result = new ArrayList<>();
Map<String, List<String>> vals = WmiUtil.selectStringsFrom(null, "Win32_DiskDrive",
"Name,Manufacturer,Model,SerialNumber,Size"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static Display[] getDisplays() {
List<Display> displays = new ArrayList<Display>();
ArrayList<String> xrandr = ExecutingCommand.runNative("xrandr --verbose");
if (xrandr != null) {
boolean foundEdid = false;
StringBuilder... | #vulnerable code
public static Display[] getDisplays() {
List<Display> displays = new ArrayList<Display>();
ArrayList<String> xrandr = ExecutingCommand.runNative("xrandr --verbose");
boolean foundEdid = false;
StringBuilder sb = new StringBuilder();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static Map<Integer, PerfCounterBlock> buildProcessMapFromPerfCounters(Collection<Integer> pids) {
Map<Integer, PerfCounterBlock> processMap = new HashMap<>();
Pair<List<String>, Map<ProcessPerformanceProperty, List<Long>>> instanceValues = ProcessInform... | #vulnerable code
public static Map<Integer, PerfCounterBlock> buildProcessMapFromPerfCounters(Collection<Integer> pids) {
Map<Integer, PerfCounterBlock> processMap = new HashMap<>();
Pair<List<String>, Map<ProcessPerformanceProperty, List<Long>>> instanceValues = Process... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public float getProcessorLoad() {
Scanner in = null;
try {
in = new Scanner(new FileReader("/proc/stat"));
} catch (FileNotFoundException e) {
System.err.println("Problem with: /proc/stat");
System.err.println(e.getMessage());
return -1;
}
in.useDelimiter("... | #vulnerable code
public float getProcessorLoad() {
// should be same as on Mac. Not tested.
ArrayList<String> topResult = ExecutingCommand.runNative("top -l 1 -R -F -n1"); // cpu load is in [3]
String[] idle = topResult.get(3).split(" "); // idle value is in [6]
return 100 - Float... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public long getAvailable() {
long availableMemory = 0;
List<String> memInfo = null;
try {
memInfo = FileUtil.readFile("/proc/meminfo");
} catch (IOException e) {
System.err.println("Problem with: /proc/meminfo");
System.err.println(e.getMessage());
return ava... | #vulnerable code
public long getAvailable() {
long returnCurrentUsageMemory = 0;
Scanner in = null;
try {
in = new Scanner(new FileReader("/proc/meminfo"));
} catch (FileNotFoundException e) {
return returnCurrentUsageMemory;
}
in.useDelimiter("\n");
while (in.hasNext()... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static ArrayList<String> runNative(String cmdToRun) {
Process p = null;
try {
p = Runtime.getRuntime().exec(cmdToRun);
//p.waitFor();
} catch (IOException e) {
return null;
}
BufferedReader reader = new BufferedReader(new InputStreamReader(
p.getIn... | #vulnerable code
public static ArrayList<String> runNative(String cmdToRun) {
Process p = null;
try {
p = Runtime.getRuntime().exec(cmdToRun);
p.waitFor();
} catch (IOException e) {
return null;
} catch (InterruptedException e) {
return null;
}
BufferedReader reade... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public double getCpuVoltage() {
// Initialize
double volts = 0d;
// If we couldn't get through normal WMI go directly to OHM
if (this.voltIdentifierStr != null) {
double[] vals = wmiGetValuesForKeys("/namespace:\\\\roo... | #vulnerable code
@Override
public double getCpuVoltage() {
ArrayList<String> hwInfo = ExecutingCommand.runNative("wmic cpu get CurrentVoltage");
for (String checkLine : hwInfo) {
if (checkLine.length() == 0 || checkLine.toLowerCase().contains("currentvolt... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void populateReadWriteMaps() {
// Although the field names say "PerSec" this is the Raw Data from which
// the associated fields are populated in the Formatted Data class, so
// in fact this is the data we want
Map<String, List<Object>>... | #vulnerable code
private void populateReadWriteMaps() {
// Although the field names say "PerSec" this is the Raw Data from which
// the associated fields are populated in the Formatted Data class, so
// in fact this is the data we want
Map<String, List<St... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean updateAttributes() {
try {
File ifDir = new File(String.format("/sys/class/net/%s/statistics", getName()));
if (!ifDir.isDirectory()) {
return false;
}
} catch (SecurityException ... | #vulnerable code
@Override
public boolean updateAttributes() {
try {
File ifDir = new File(String.format("/sys/class/net/%s/statistics", getName()));
if (!ifDir.isDirectory()) {
return false;
}
} catch (SecurityExce... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void populateReadWriteMaps() {
// Although the field names say "PerSec" this is the Raw Data from which
// the associated fields are populated in the Formatted Data class, so
// in fact this is the data we want
Map<String, List<Object>>... | #vulnerable code
private void populateReadWriteMaps() {
// Although the field names say "PerSec" this is the Raw Data from which
// the associated fields are populated in the Formatted Data class, so
// in fact this is the data we want
Map<String, List<St... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public long[] querySystemCpuLoadTicks() {
// To get load in processor group scenario, we need perfmon counters, but the
// _Total instance is an average rather than total (scaled) number of ticks
// which matches GetSystemTimes() results.... | #vulnerable code
@Override
public long[] querySystemCpuLoadTicks() {
long[] ticks = new long[TickType.values().length];
WinBase.FILETIME lpIdleTime = new WinBase.FILETIME();
WinBase.FILETIME lpKernelTime = new WinBase.FILETIME();
WinBase.FILETIME lpUs... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void populatePartitionMaps() {
driveToPartitionMap.clear();
partitionToLogicalDriveMap.clear();
partitionMap.clear();
// For Regexp matching DeviceIDs
Matcher mAnt;
Matcher mDep;
// Map drives to partitions
... | #vulnerable code
private void populatePartitionMaps() {
driveToPartitionMap.clear();
partitionToLogicalDriveMap.clear();
partitionMap.clear();
// For Regexp matching DeviceIDs
Matcher mAnt;
Matcher mDep;
// Map drives to partition... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<Object>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD... | #vulnerable code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<String>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectStringsFrom(null, "Win32_Lo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void removeAllCounters() {
// Remove all counters from counterHandle map
for (HANDLEByReference href : counterHandleMap.values()) {
PerfDataUtil.removeCounter(href);
}
counterHandleMap.clear();
// Remove query
... | #vulnerable code
public void removeAllCounters() {
// Remove all counter handles
for (HANDLEByReference href : counterHandleMap.values()) {
PerfDataUtil.removeCounter(href);
}
counterHandleMap.clear();
// Remove all queries
for... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void populatePartitionMaps() {
driveToPartitionMap.clear();
partitionToLogicalDriveMap.clear();
partitionMap.clear();
// For Regexp matching DeviceIDs
Matcher mAnt;
Matcher mDep;
// Map drives to partitions
... | #vulnerable code
private void populatePartitionMaps() {
driveToPartitionMap.clear();
partitionToLogicalDriveMap.clear();
partitionMap.clear();
// For Regexp matching DeviceIDs
Matcher mAnt;
Matcher mDep;
// Map drives to partition... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public long[] querySystemCpuLoadTicks() {
// To get load in processor group scenario, we need perfmon counters, but the
// _Total instance is an average rather than total (scaled) number of ticks
// which matches GetSystemTimes() results.... | #vulnerable code
@Override
public long[] querySystemCpuLoadTicks() {
long[] ticks = new long[TickType.values().length];
WinBase.FILETIME lpIdleTime = new WinBase.FILETIME();
WinBase.FILETIME lpKernelTime = new WinBase.FILETIME();
WinBase.FILETIME lpUs... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public int[] getFanSpeeds() {
// Initialize
int[] fanSpeeds = new int[1];
// If we couldn't get through normal WMI go directly to OHM
if (!this.fanSpeedWMI) {
double[] vals = wmiGetValuesForKeys("/namespace:\\\\root\\O... | #vulnerable code
@Override
public int[] getFanSpeeds() {
int[] fanSpeeds = new int[1];
ArrayList<String> hwInfo = ExecutingCommand
.runNative("wmic /namespace:\\\\root\\cimv2 PATH Win32_Fan get DesiredSpeed");
for (String checkLine : hwInfo) {... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static UsbDevice[] getUsbDevices() {
// Start by collecting information for all PNP devices. While in theory
// these could be individually queried with a WHERE clause, grabbing
// them all up front incurs minimal memory overhead in exchange for... | #vulnerable code
public static UsbDevice[] getUsbDevices() {
List<UsbDevice> usbDevices = new ArrayList<UsbDevice>();
// Store map of pnpID to name, Manufacturer, serial
Map<String, String> nameMap = new HashMap<>();
Map<String, String> vendorMap = new H... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator,
String[] properties, ValueType[] propertyTypes) {
if (propertyTypes.length > 1 && properties.length != propertyTypes.length) {
throw new I... | #vulnerable code
private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator,
String[] properties, ValueType[] propertyTypes) {
if (propertyTypes.length > 1 && properties.length != propertyTypes.length) {
throw... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public long getSwapUsed() {
PdhFmtCounterValue phPagefileCounterValue = new PdhFmtCounterValue();
int ret = Pdh.INSTANCE.PdhGetFormattedCounterValue(pPagefile.getValue(), Pdh.PDH_FMT_LARGE | Pdh.PDH_FMT_1000,
null, phPagefileCount... | #vulnerable code
@Override
public long getSwapUsed() {
long total;
long available;
if (!Kernel32.INSTANCE.GlobalMemoryStatusEx(this._memory)) {
LOG.error("Failed to Initialize MemoryStatusEx. Error code: {}", Kernel32.INSTANCE.GetLastErro... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<Object>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD... | #vulnerable code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<String>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectStringsFrom(null, "Win32_Lo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public HWDiskStore[] getDisks() {
List<HWDiskStore> result;
result = new ArrayList<>();
readMap.clear();
writeMap.clear();
populateReadWriteMaps();
Map<String, List<Object>> vals = WmiUtil.selectObjectsFrom(null, ... | #vulnerable code
@Override
public HWDiskStore[] getDisks() {
List<HWDiskStore> result;
result = new ArrayList<>();
Map<String, List<String>> vals = WmiUtil.selectStringsFrom(null, "Win32_DiskDrive",
"Name,Manufacturer,Model,SerialNumber,Size"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public HWDiskStore[] getDisks() {
List<HWDiskStore> result;
result = new ArrayList<>();
readMap.clear();
writeMap.clear();
populateReadWriteMaps();
Map<String, List<Object>> vals = WmiUtil.selectObjectsFrom(null, ... | #vulnerable code
@Override
public HWDiskStore[] getDisks() {
List<HWDiskStore> result;
result = new ArrayList<>();
Map<String, List<String>> vals = WmiUtil.selectStringsFrom(null, "Win32_DiskDrive",
"Name,Manufacturer,Model,SerialNumber,Size"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public long[] querySystemCpuLoadTicks() {
// convert the Linux Jiffies to Milliseconds.
long[] ticks = CpuStat.getSystemCpuLoadTicks();
// In rare cases, /proc/stat reading fails. If so, try again.
if (LongStream.of(ticks).sum() =... | #vulnerable code
@Override
public long[] querySystemCpuLoadTicks() {
// convert the Linux Jiffies to Milliseconds.
long[] ticks = CpuStat.getSystemCpuLoadTicks();
long hz = LinuxOperatingSystem.getHz();
for (int i = 0; i < ticks.length; i++) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void removeAllCounters() {
// Remove all counters from counterHandle map
for (HANDLEByReference href : counterHandleMap.values()) {
PerfDataUtil.removeCounter(href);
}
counterHandleMap.clear();
// Remove query
... | #vulnerable code
public void removeAllCounters() {
// Remove all counter handles
for (HANDLEByReference href : counterHandleMap.values()) {
PerfDataUtil.removeCounter(href);
}
counterHandleMap.clear();
// Remove all queries
for... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static String getCardCodec(File cardDir) {
String cardCodec = "";
File[] cardFiles = cardDir.listFiles();
if (cardFiles == null) {
return "";
}
for (File file : cardDir.listFiles()) {
if (file.getName().s... | #vulnerable code
private static String getCardCodec(File cardDir) {
String cardCodec = "";
for (File file : cardDir.listFiles()) {
if (file.getName().startsWith("codec")) {
cardCodec = FileUtil.getKeyValueMapFromFile(file.getPath(), ":").get("... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public String getSystemSerialNumber() {
if (this.cpuSerialNumber == null) {
int service = 0;
MachPort masterPort = new MachPort();
int result = IOKit.INSTANCE.IOMasterPort(0, masterPort);
if (result != 0) {... | #vulnerable code
@Override
public String getSystemSerialNumber() {
if (this.cpuSerialNumber == null) {
ArrayList<String> hwInfo = ExecutingCommand.runNative("system_profiler SPHardwareDataType");
// Mavericks and later
for (String checkLin... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static ArrayList<String> runNative(String cmdToRun) {
Process p = null;
try {
p = Runtime.getRuntime().exec(cmdToRun);
} catch (IOException e) {
LOG.trace("", e);
return null;
}
BufferedReader... | #vulnerable code
public static ArrayList<String> runNative(String cmdToRun) {
Process p = null;
try {
p = Runtime.getRuntime().exec(cmdToRun);
p.waitFor();
} catch (IOException e) {
LOG.trace("", e);
return null;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator,
String[] properties, ValueType[] propertyTypes) {
if (propertyTypes.length > 1 && properties.length != propertyTypes.length) {
throw new I... | #vulnerable code
private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator,
String[] properties, ValueType[] propertyTypes) {
if (propertyTypes.length > 1 && properties.length != propertyTypes.length) {
throw... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static <T extends Enum<T>> Map<T, Long> queryValues(Class<T> propertyEnum, String perfObject,
String perfWmiClass) {
// Check without locking for performance
if (!failedQueryCache.contains(perfObject)) {
failedQueryCacheLock.lock... | #vulnerable code
public static <T extends Enum<T>> Map<T, Long> queryValues(Class<T> propertyEnum, String perfObject,
String perfWmiClass) {
Map<T, Long> valueMap = queryValuesFromPDH(propertyEnum, perfObject);
if (valueMap.isEmpty()) {
return que... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<Object>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD... | #vulnerable code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<String>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectStringsFrom(null, "Win32_Lo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public HWDiskStore[] getDisks() {
List<HWDiskStore> result;
result = new ArrayList<>();
readMap.clear();
writeMap.clear();
populateReadWriteMaps();
Map<String, List<Object>> vals = WmiUtil.selectObjectsFrom(null, ... | #vulnerable code
@Override
public HWDiskStore[] getDisks() {
List<HWDiskStore> result;
result = new ArrayList<>();
Map<String, List<String>> vals = WmiUtil.selectStringsFrom(null, "Win32_DiskDrive",
"Name,Manufacturer,Model,SerialNumber,Size"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static boolean updateDiskStats(HWDiskStore diskStore, DASessionRef session,
Map<String, String> mountPointMap, Map<String, String> logicalVolumeMap, Map<CFKey, CFStringRef> cfKeyMap) {
// Now look up the device using the BSD Name to get its
... | #vulnerable code
private static boolean updateDiskStats(HWDiskStore diskStore, DASessionRef session,
Map<String, String> mountPointMap, Map<String, String> logicalVolumeMap, Map<CFKey, CFStringRef> cfKeyMap) {
// Now look up the device using the BSD Name to get its
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static <T extends Enum<T>> Pair<List<String>, Map<T, List<Long>>> queryInstancesAndValues(
Class<T> propertyEnum, String perfObject, String perfWmiClass) {
// Check without locking for performance
if (!failedQueryCache.contains(perfObject)) ... | #vulnerable code
public static <T extends Enum<T>> Pair<List<String>, Map<T, List<Long>>> queryInstancesAndValues(
Class<T> propertyEnum, String perfObject, String perfWmiClass) {
Pair<List<String>, Map<T, List<Long>>> instancesAndValuesMap = queryInstancesAndValuesF... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected void updateMeminfo() {
long now = System.currentTimeMillis();
if (now - this.lastUpdate > 100) {
if (!Psapi.INSTANCE.GetPerformanceInfo(perfInfo, perfInfo.size())) {
LOG.error("Failed to get Performance Info. Error code: {... | #vulnerable code
protected void updateMeminfo() {
long now = System.currentTimeMillis();
if (now - this.lastUpdate > 100) {
if (!Psapi.INSTANCE.GetPerformanceInfo(perfInfo, perfInfo.size())) {
LOG.error("Failed to get Performance Info. Error c... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator,
String[] properties, ValueType[] propertyTypes) {
if (propertyTypes.length > 1 && properties.length != propertyTypes.length) {
throw new I... | #vulnerable code
private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator,
String[] properties, ValueType[] propertyTypes) {
if (propertyTypes.length > 1 && properties.length != propertyTypes.length) {
throw... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<Object>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD... | #vulnerable code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<String>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectStringsFrom(null, "Win32_Lo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static Memory sysctl(String name) {
IntByReference size = new IntByReference();
if (0 != FreeBsdLibc.INSTANCE.sysctlbyname(name, null, size, null, 0)) {
LOG.error(SYSCTL_FAIL, name, Native.getLastError());
return null;
}
... | #vulnerable code
public static Memory sysctl(String name) {
IntByReference size = new IntByReference();
if (0 != SystemB.INSTANCE.sysctlbyname(name, null, size, null, 0)) {
LOG.error(SYSCTL_FAIL, name, Native.getLastError());
return null;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static <T extends Enum<T>> Map<T, Long> queryValues(Class<T> propertyEnum, String perfObject,
String perfWmiClass) {
// Check without locking for performance
if (!failedQueryCache.contains(perfObject)) {
failedQueryCacheLock.lock... | #vulnerable code
public static <T extends Enum<T>> Map<T, Long> queryValues(Class<T> propertyEnum, String perfObject,
String perfWmiClass) {
Map<T, Long> valueMap = queryValuesFromPDH(propertyEnum, perfObject);
if (valueMap.isEmpty()) {
return que... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public long[][] queryProcessorCpuLoadTicks() {
long[][] ticks = CpuStat.getProcessorCpuLoadTicks(getLogicalProcessorCount());
// In rare cases, /proc/stat reading fails. If so, try again.
// In theory we should check all of them, but on f... | #vulnerable code
@Override
public long[][] queryProcessorCpuLoadTicks() {
long[][] ticks = CpuStat.getProcessorCpuLoadTicks(getLogicalProcessorCount());
// convert the Linux Jiffies to Milliseconds.
long hz = LinuxOperatingSystem.getHz();
for (int i =... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public OSFileStore[] getFileStores() {
// Use getfsstat to map filesystem paths to types
Map<String, String> fstype = new HashMap<>();
// Query with null to get total # required
int numfs = SystemB.INSTANCE.getfsstat64(null, 0, 0);
if (... | #vulnerable code
public OSFileStore[] getFileStores() {
// Use getfsstat to map filesystem paths to types
Map<String, String> fstype = new HashMap<>();
// Query with null to get total # required
int numfs = SystemB.INSTANCE.getfsstat64(null, 0, 0);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public double getCpuTemperature() {
// Initialize
double tempC = 0d;
// If Open Hardware Monitor identifier is set, we couldn't get through
// normal WMI, and got ID from OHM at least once so go directly to OHM
if (this.te... | #vulnerable code
@Override
public double getCpuTemperature() {
ArrayList<String> hwInfo = ExecutingCommand.runNative("wmic Temperature get CurrentReading");
for (String checkLine : hwInfo) {
if (checkLine.length() == 0 || checkLine.toLowerCase().contains(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public long[] querySystemCpuLoadTicks() {
// To get load in processor group scenario, we need perfmon counters, but the
// _Total instance is an average rather than total (scaled) number of ticks
// which matches GetSystemTimes() results.... | #vulnerable code
@Override
public long[] querySystemCpuLoadTicks() {
long[] ticks = new long[TickType.values().length];
WinBase.FILETIME lpIdleTime = new WinBase.FILETIME();
WinBase.FILETIME lpKernelTime = new WinBase.FILETIME();
WinBase.FILETIME lpUs... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void populateReadWriteMaps() {
// Although the field names say "PerSec" this is the Raw Data from which
// the associated fields are populated in the Formatted Data class, so
// in fact this is the data we want
Map<String, List<Object>>... | #vulnerable code
private void populateReadWriteMaps() {
// Although the field names say "PerSec" this is the Raw Data from which
// the associated fields are populated in the Formatted Data class, so
// in fact this is the data we want
Map<String, List<St... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private DmidecodeStrings readDmiDecode() {
String manufacturer = null;
String version = null;
String releaseDate = "";
// $ sudo dmidecode -t bios
// # dmidecode 3.0
// Scanning /dev/mem for entry point.
// SMBIOS 2.7 p... | #vulnerable code
private DmidecodeStrings readDmiDecode() {
String manufacturer = null;
String version = null;
String releaseDate = null;
// $ sudo dmidecode -t bios
// # dmidecode 3.0
// Scanning /dev/mem for entry point.
// SMBI... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator,
String[] properties, ValueType[] propertyTypes) {
if (propertyTypes.length > 1 && properties.length != propertyTypes.length) {
throw new I... | #vulnerable code
private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator,
String[] properties, ValueType[] propertyTypes) {
if (properties.length != propertyTypes.length) {
throw new IllegalArgumentExceptio... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void updateSwap() {
updateMeminfo();
this.swapUsed = PdhUtil.queryCounter(pdhPagingPercentUsageCounter) * this.pageSize;
} | #vulnerable code
@Override
protected void updateSwap() {
updateMeminfo();
Map<String, List<Long>> usage = WmiUtil.selectUint32sFrom(null, "Win32_PerfRawData_PerfOS_PagingFile",
"PercentUsage,PercentUsage_Base", "WHERE Name=\"_Total\"");
if (!u... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public long getTotal() {
if (totalMemory == 0) {
Sysinfo info = new Sysinfo();
if (0 != Libc.INSTANCE.sysinfo(info))
throw new LastErrorException("Error code: "
+ Native.getLastError());
totalMemory = info.totalram.longValue() * info.mem_unit;
}
return t... | #vulnerable code
public long getTotal() {
if (totalMemory == 0) {
Scanner in = null;
try {
in = new Scanner(new FileReader("/proc/meminfo"));
} catch (FileNotFoundException e) {
totalMemory = 0;
return totalMemory;
}
in.useDelimiter("\n");
while (in.hasNext(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static UsbDevice[] getUsbDevices() {
// Reusable buffer for getting IO name strings
Pointer buffer = new Memory(128); // io_name_t is char[128]
// Build a list of devices with no parent; these will be the roots
List<Long> usbControllers ... | #vulnerable code
public static UsbDevice[] getUsbDevices() {
// Get heirarchical list of USB devices
List<String> xml = ExecutingCommand.runNative("system_profiler SPUSBDataType -xml");
// Look for <key>_items</key> which prcedes <array> ... </array>
// E... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static ArrayList<String> runNative(String[] cmdToRunWithArgs) {
Process p = null;
try {
p = Runtime.getRuntime().exec(cmdToRunWithArgs);
} catch (IOException e) {
LOG.trace("", e);
return null;
}
... | #vulnerable code
public static ArrayList<String> runNative(String[] cmdToRunWithArgs) {
Process p = null;
try {
p = Runtime.getRuntime().exec(cmdToRunWithArgs);
} catch (IOException e) {
LOG.trace("", e);
return null;
}... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public String getFamily() {
if (this._family == null) {
String etcOsRelease = getReleaseFilename();
try {
this.osRelease = FileUtil.readFile(etcOsRelease);
for (String line : this.osRelease) {
... | #vulnerable code
@Override
public String getFamily() {
if (this._family == null) {
try (final Scanner in = new Scanner(new FileReader("/etc/os-release"))) {
in.useDelimiter("\n");
while (in.hasNext()) {
String[]... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<Object>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD... | #vulnerable code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<String>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectStringsFrom(null, "Win32_Lo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean updateAttributes() {
try {
File ifDir = new File(String.format("/sys/class/net/%s/statistics", getName()));
if (!ifDir.isDirectory()) {
return false;
}
} catch (SecurityException ... | #vulnerable code
@Override
public boolean updateAttributes() {
try {
File ifDir = new File(String.format("/sys/class/net/%s/statistics", getName()));
if (!ifDir.isDirectory()) {
return false;
}
} catch (SecurityExce... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<Object>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD... | #vulnerable code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<String>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectStringsFrom(null, "Win32_Lo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static Memory sysctl(String name) {
IntByReference size = new IntByReference();
if (0 != FreeBsdLibc.INSTANCE.sysctlbyname(name, null, size, null, 0)) {
LOG.error(SYSCTL_FAIL, name, Native.getLastError());
return null;
}
... | #vulnerable code
public static Memory sysctl(String name) {
IntByReference size = new IntByReference();
if (0 != SystemB.INSTANCE.sysctlbyname(name, null, size, null, 0)) {
LOG.error(SYSCTL_FAIL, name, Native.getLastError());
return null;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public OSService[] getServices() {
// Get running services
List<OSService> services = new ArrayList<>();
Set<String> running = new HashSet<>();
for (OSProcess p : getChildProcesses(1, 0, ProcessSort.PID)) {
OSService s... | #vulnerable code
@Override
public OSService[] getServices() {
// Get running services
List<OSService> services = new ArrayList<>();
Set<String> running = new HashSet<>();
for (OSProcess p : getChildProcesses(1, 0, ProcessSort.PID)) {
OSSer... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void populatePartitionMaps() {
driveToPartitionMap.clear();
partitionToLogicalDriveMap.clear();
partitionMap.clear();
// For Regexp matching DeviceIDs
Matcher mAnt;
Matcher mDep;
// Map drives to partitions
... | #vulnerable code
private void populatePartitionMaps() {
driveToPartitionMap.clear();
partitionToLogicalDriveMap.clear();
partitionMap.clear();
// For Regexp matching DeviceIDs
Matcher mAnt;
Matcher mDep;
// Map drives to partition... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator,
String[] properties, ValueType[] propertyTypes, WbemServices svc) {
if (propertyTypes.length > 1 && properties.length != propertyTypes.length) {
... | #vulnerable code
private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator,
String[] properties, ValueType[] propertyTypes, WbemServices svc) {
if (propertyTypes.length > 1 && properties.length != propertyTypes.length) {... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<Object>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectObjectsFrom(null, "Win32_LogicalD... | #vulnerable code
private List<OSFileStore> getWmiVolumes() {
Map<String, List<String>> drives;
List<OSFileStore> fs;
String volume;
long free;
long total;
fs = new ArrayList<>();
drives = WmiUtil.selectStringsFrom(null, "Win32_Lo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static <T extends Enum<T>> Pair<List<String>, Map<T, List<Long>>> queryInstancesAndValues(
Class<T> propertyEnum, String perfObject, String perfWmiClass) {
// Check without locking for performance
if (!failedQueryCache.contains(perfObject)) ... | #vulnerable code
public static <T extends Enum<T>> Pair<List<String>, Map<T, List<Long>>> queryInstancesAndValues(
Class<T> propertyEnum, String perfObject, String perfWmiClass) {
Pair<List<String>, Map<T, List<Long>>> instancesAndValuesMap = queryInstancesAndValuesF... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static UsbDevice[] getUsbDevices() {
// Start by collecting information for all PNP devices. While in theory
// these could be individually queried with a WHERE clause, grabbing
// them all up front incurs minimal memory overhead in exchange for... | #vulnerable code
public static UsbDevice[] getUsbDevices() {
// Start by collecting information for all PNP devices. While in theory
// these could be individually queried with a WHERE clause, grabbing
// them all up front incurs minimal memory overhead in exchan... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public HWDiskStore[] getDisks() {
List<HWDiskStore> result;
result = new ArrayList<>();
readMap.clear();
writeMap.clear();
populateReadWriteMaps();
Map<String, List<Object>> vals = WmiUtil.selectObjectsFrom(null, ... | #vulnerable code
@Override
public HWDiskStore[] getDisks() {
List<HWDiskStore> result;
result = new ArrayList<>();
Map<String, List<String>> vals = WmiUtil.selectStringsFrom(null, "Win32_DiskDrive",
"Name,Manufacturer,Model,SerialNumber,Size"... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static ArrayList<String> runNative(String cmdToRun) {
Process p = null;
try {
p = Runtime.getRuntime().exec(cmdToRun);
p.waitFor();
} catch (IOException e) {
return null;
} catch (InterruptedException e) {
e.printStackTrace();
}
BufferedReader rea... | #vulnerable code
public static ArrayList<String> runNative(String cmdToRun) {
Process p = null;
try {
p = Runtime.getRuntime().exec(cmdToRun);
//p.waitFor();
} catch (IOException e) {
return null;
}
BufferedReader reader = new BufferedReader(new InputStreamReader(
p... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator,
String[] properties, ValueType[] propertyTypes) {
if (propertyTypes.length > 1 && properties.length != propertyTypes.length) {
throw new I... | #vulnerable code
private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator,
String[] properties, ValueType[] propertyTypes) {
if (propertyTypes.length > 1 && properties.length != propertyTypes.length) {
throw... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void updateSwap() {
updateMeminfo();
this.swapUsed = PdhUtil.queryCounter(pdhPagingPercentUsageCounter) * this.pageSize;
} | #vulnerable code
@Override
protected void updateSwap() {
updateMeminfo();
Map<String, List<Long>> usage = WmiUtil.selectUint32sFrom(null, "Win32_PerfRawData_PerfOS_PagingFile",
"PercentUsage,PercentUsage_Base", "WHERE Name=\"_Total\"");
if (!u... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
@SuppressWarnings("unchecked")
public void chainArray() {
final List<Map<String, Object>> stooges = new ArrayList<Map<String, Object>>() { {
add(new LinkedHashMap<String, Object>() { { put("name", "curly"); put("age", 25); } });
a... | #vulnerable code
@Test
@SuppressWarnings("unchecked")
public void chainArray() {
final List<Map<String, Object>> stooges = new ArrayList<Map<String, Object>>() { {
add(new LinkedHashMap<String, Object>() { { put("name", "curly"); put("age", 25); } });
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void find() {
final Optional<Integer> result = _.find(asList(1, 2, 3, 4, 5, 6),
new Predicate<Integer>() {
public Boolean apply(Integer item) {
return item % 2 == 0;
}
});
assertEqual... | #vulnerable code
@Test
public void find() {
final Integer result = _.find(asList(1, 2, 3, 4, 5, 6),
new Predicate<Integer>() {
public Boolean apply(Integer item) {
return item % 2 == 0;
}
});
assertEquals("... | Below is the vulnerable code, please generate the patch based on the following information. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.