output stringlengths 64 73.2k | input stringlengths 208 73.3k | instruction stringclasses 1
value |
|---|---|---|
#fixed code
@Override
public void run() {
try {
LOGGER.info(I18n.UPDATE_LOADING);
URLConnection con = new URL("https://raw.githubusercontent.com/ron190/jsql-injection/master/.version").openConnection();
con.setReadTimeout(60000);
... | #vulnerable code
@Override
public void run() {
try {
LOGGER.info(I18n.UPDATE_LOADING);
URLConnection con = new URL("http://jsql-injection.googlecode.com/git/.version").openConnection();
con.setReadTimeout(60000);
con.setConnect... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | #vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | #vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | #vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | #vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | #vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
// Transform only SQL query without HTTP parameters and syntax changed, like p=1'+[sql]
Matcher matcherSql... | #vulnerable code
public String tamper(String sqlQueryDefault) {
String lead = null;
String sqlQuery = null;
String trail = null;
Matcher matcherSql = Pattern.compile("(?s)(.*<tampering>)(.*)(</tampering>.*)").matcher(sqlQueryDefault);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void run() {
try {
LOGGER.info(I18n.UPDATE_LOADING);
URLConnection con = new URL("https://raw.githubusercontent.com/ron190/jsql-injection/master/.version").openConnection();
con.setReadTimeout(60000);
... | #vulnerable code
@Override
public void run() {
try {
LOGGER.info(I18n.UPDATE_LOADING);
URLConnection con = new URL("http://jsql-injection.googlecode.com/git/.version").openConnection();
con.setReadTimeout(60000);
con.setConnect... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void start(Class<?> clazz,String path) throws Exception {
InitSetting.setting(clazz,path) ;
NettyBootStrap.startServer();
} | #vulnerable code
public static void start(Class<?> clazz,String path) throws Exception {
long start = System.currentTimeMillis();
//init application
AppConfig.getInstance().setRootPackageName(clazz.getPackage().getName());
AppConfig.getInstance().setRo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void handlePostValidate(UIInput component) {
BeanValidator beanValidator = getBeanValidator(component);
if (beanValidator != null) {
String originalValidationGroups = (String) component.getAttributes().remove(ATTRIBUTE_ORIGINAL_VALIDATION_GROUPS);
beanValidato... | #vulnerable code
private void handlePostValidate(UIInput component) {
final BeanValidator beanValidator = getBeanValidator(component);
final String originalValidationGroups = (String) component.getAttributes().remove(ATTRIBUTE_ORIGINAL_VALIDATION_GROUPS);
beanValidator.setValidationG... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void apply(FaceletContext context, UIComponent parent) throws IOException {
if (!ComponentHandler.isNew(parent)) {
return;
}
if (!TRUE.equals(getApplicationAttribute(context.getFacesContext(), Socket.class.getName()))) {
throw new IllegalStateExcep... | #vulnerable code
@Override
public void apply(FaceletContext context, UIComponent parent) throws IOException {
if (!ComponentHandler.isNew(parent)) {
return;
}
if (!TRUE.equals(getApplicationAttribute(context.getFacesContext(), Socket.class.getName()))) {
throw new IllegalStat... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static <T> T getInstance(BeanManager beanManager, Class<T> beanClass) {
Bean<T> bean = resolve(beanManager, beanClass);
return (bean != null) ? getInstance(beanManager, bean, true) : null;
} | #vulnerable code
public static <T> T getInstance(BeanManager beanManager, Class<T> beanClass) {
return getInstance(beanManager, resolve(beanManager, beanClass), true);
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void encodeBegin(FacesContext context) throws IOException {
Components.validateHasNoChildren(this);
ExternalContext externalContext = context.getExternalContext();
HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
HttpServ... | #vulnerable code
@Override
public void encodeBegin(FacesContext context) throws IOException {
Components.validateHasNoChildren(this);
try {
ExternalContext externalContext = context.getExternalContext();
HttpServletRequest request = (HttpServletRequest) externalContext.getReque... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@OnClose
public void close(Session session) {
BeanManager.INSTANCE.getReference(SocketPushContext.class).remove(session); // @Inject in @ServerEndpoint doesn't work in Tomcat+Weld.
} | #vulnerable code
@OnClose
public void close(Session session) {
BeanManager.INSTANCE.getReference(PushContextImpl.class).remove(session); // @Inject in @ServerEndpoint doesn't work in Tomcat+Weld.
}
#location 3
#vulnerability typ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private synchronized void loadResources() {
if (!isEmpty(resources)) {
return;
}
FacesContext context = FacesContext.getCurrentInstance();
resources = new LinkedHashSet<>();
contentLength = 0;
lastModified = 0;
for (ResourceIdentifier resourceIdentifier : reso... | #vulnerable code
private synchronized void loadResources() {
if (!isEmpty(resources)) {
return;
}
FacesContext context = FacesContext.getCurrentInstance();
ResourceHandler handler = context.getApplication().getResourceHandler();
resources = new LinkedHashSet<>();
contentLen... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static <T> T getReference(BeanManager beanManager, Class<T> beanClass) {
Bean<T> bean = resolve(beanManager, beanClass);
return (bean != null) ? getReference(beanManager, bean) : null;
} | #vulnerable code
public static <T> T getReference(BeanManager beanManager, Class<T> beanClass) {
return getReference(beanManager, resolve(beanManager, beanClass));
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@OnOpen
public void open(Session session, @PathParam("channel") String channel) {
BeanManager.INSTANCE.getReference(SocketPushContext.class).add(session, channel); // @Inject in @ServerEndpoint doesn't work in Tomcat+Weld.
} | #vulnerable code
@OnOpen
public void open(Session session, @PathParam("channel") String channel) {
BeanManager.INSTANCE.getReference(PushContextImpl.class).add(session, channel); // @Inject in @ServerEndpoint doesn't work in Tomcat+Weld.
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public <S extends Serializable> Map<S, Set<Future<Void>>> send(Object message, Collection<S> users) {
Map<S, Set<Future<Void>>> resultsByUser = new HashMap<>(users.size());
for (S user : users) {
Set<String> userChannelIds = userManager.getUserChannelIds(user,... | #vulnerable code
@Override
public <S extends Serializable> Map<S, Set<Future<Void>>> send(Object message, Collection<S> users) {
SocketSessionManager manager = SocketSessionManager.getInstance();
Map<S, Set<Future<Void>>> resultsByUser = new HashMap<>(users.size());
for (S user : u... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PreDestroyViewMapEvent) {
getReference(ViewScopeManager.class).preDestroyView();
}
} | #vulnerable code
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PreDestroyViewMapEvent) {
BeanManager.INSTANCE.getReference(ViewScopeManager.class).preDestroyView();
}
}
#location 4
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public String getActionURL(FacesContext context, String viewId) {
String actionURL = super.getActionURL(context, viewId);
ServletContext servletContext = getServletContext(context);
Map<String, String> mappedResources = getMappedResources(servletContext);
if ... | #vulnerable code
@Override
public String getActionURL(FacesContext context, String viewId) {
String actionURL = super.getActionURL(context, viewId);
ServletContext servletContext = getServletContext(context);
Map<String, String> mappedResources = getMappedResources(servletContext);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@SuppressWarnings("unchecked")
public static <T> void destroy(BeanManager beanManager, T instance) {
if (instance instanceof Class) { // Java prefers T over Class<T> when varargs is not specified :(
destroy(beanManager, (Class<T>) instance, new Annotation[0]);
}
else {... | #vulnerable code
@SuppressWarnings("unchecked")
public static <T> void destroy(BeanManager beanManager, T instance) {
if (instance instanceof Class) {
destroy(beanManager, (Class<T>) instance, new Annotation[0]);
}
else if (instance instanceof Bean) {
destroy(beanManager, (Bea... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public UIViewRoot restoreView(FacesContext context, String viewId) {
if (isUnloadRequest(context)) {
UIViewRoot createdView = createView(context, viewId);
createdView.restoreViewScopeState(context, getRenderKit(context).getResponseStateManager().getState(conte... | #vulnerable code
@Override
public UIViewRoot restoreView(FacesContext context, String viewId) {
if (isUnloadRequest(context)) {
UIViewRoot createdView = createView(context, viewId);
createdView.restoreViewScopeState(context, getRenderKit(context).getResponseStateManager().getState... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void contextInitialized(ServletContextEvent event) {
checkCDIAvailable();
EagerBeansRepository.getInstance().instantiateApplicationScoped();
FacesViews.addMappings(event.getServletContext());
CacheInitializer.loadProviderAndRegisterFilter(event.getServl... | #vulnerable code
@Override
public void contextInitialized(ServletContextEvent event) {
checkCDIAvailable();
BeanManager.INSTANCE.getReference(EagerBeansRepository.class).instantiateApplicationScoped();
FacesViews.addMappings(event.getServletContext());
CacheInitializer.loadProvide... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) {
String string = submittedValue;
if (!isEmpty(string)) {
DecimalFormat formatter = getFormatter();
if (formatter != null) {
String symbol = getSymbol(formatt... | #vulnerable code
@Override
public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) {
String string = submittedValue;
if (!isEmpty(string)) {
DecimalFormat formatter = getFormatter();
String symbol = getSymbol(formatter);
if (!string.con... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void handlePreValidate(UIInput component) {
BeanValidator beanValidator = getBeanValidator(component);
if (beanValidator == null) {
return;
}
String newValidationGroups = disabled ? NoValidationGroup.class.getName() : validationGroups;
String originalValid... | #vulnerable code
private void handlePreValidate(UIInput component) {
final BeanValidator beanValidator = getBeanValidator(component);
final String newValidationGroups = disabled ? NoValidationGroup.class.getName() : validationGroups;
final String originalValidationGroups = beanValida... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public UIViewRoot restoreView(FacesContext context, String viewId) {
if (isUnloadRequest(context)) {
UIViewRoot createdView = createView(context, viewId);
createdView.restoreViewScopeState(context, getRenderKit(context).getResponseStateManager().getState(conte... | #vulnerable code
@Override
public UIViewRoot restoreView(FacesContext context, String viewId) {
if (isUnloadRequest(context)) {
UIViewRoot createdView = createView(context, viewId);
createdView.restoreViewScopeState(context, getRenderKit(context).getResponseStateManager().getState... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void encodeChildren(FacesContext context) throws IOException {
if (!TRUE.equals(getApplicationAttribute(context, Socket.class.getName()))) {
throw new IllegalStateException(ERROR_ENDPOINT_NOT_ENABLED);
}
if (SocketFacesListener.register(context, this)... | #vulnerable code
@Override
public void encodeChildren(FacesContext context) throws IOException {
if (!TRUE.equals(getApplicationAttribute(context, Socket.class.getName()))) {
throw new IllegalStateException(ERROR_ENDPOINT_NOT_ENABLED);
}
if (SocketFacesListener.register(context,... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void apply(FaceletContext context, UIComponent parent) throws IOException {
if (!ComponentHandler.isNew(parent)) {
return;
}
if (!TRUE.equals(getApplicationAttribute(context.getFacesContext(), Socket.class.getName()))) {
throw new IllegalStateExcep... | #vulnerable code
@Override
public void apply(FaceletContext context, UIComponent parent) throws IOException {
if (!ComponentHandler.isNew(parent)) {
return;
}
if (!TRUE.equals(getApplicationAttribute(context.getFacesContext(), Socket.class.getName()))) {
throw new IllegalStat... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void contextInitialized(ServletContextEvent event) {
checkCDIAvailable();
try {
ServletContext servletContext = event.getServletContext();
EagerBeansRepository.instantiateApplicationScopedAndRegisterListener(servletContext);
FacesViews.addMappings... | #vulnerable code
@Override
public void contextInitialized(ServletContextEvent event) {
checkCDIAvailable();
try {
EagerBeansRepository.getInstance().instantiateApplicationScoped();
FacesViews.addMappings(event.getServletContext());
CacheInitializer.loadProviderAndRegisterFil... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private synchronized void loadResources() {
if (!isEmpty(resources)) {
return;
}
FacesContext context = FacesContext.getCurrentInstance();
resources = new LinkedHashSet<>();
contentLength = 0;
lastModified = 0;
for (ResourceIdentifier resourceIdentifier : reso... | #vulnerable code
private synchronized void loadResources() {
if (!isEmpty(resources)) {
return;
}
FacesContext context = FacesContext.getCurrentInstance();
ResourceHandler handler = context.getApplication().getResourceHandler();
resources = new LinkedHashSet<>();
contentLen... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public String getActionURL(FacesContext context, String viewId) {
String actionURL = super.getActionURL(context, viewId);
ServletContext servletContext = getServletContext(context);
Map<String, String> mappedResources = getMappedResources(servletContext);
if ... | #vulnerable code
@Override
public String getActionURL(FacesContext context, String viewId) {
String actionURL = super.getActionURL(context, viewId);
ServletContext servletContext = getServletContext(context);
Map<String, String> mappedResources = getMappedResources(servletContext);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static <T> T getInstance(BeanManager beanManager, Class<T> beanClass, boolean create) {
Bean<T> bean = resolve(beanManager, beanClass);
return (bean != null) ? getInstance(beanManager, bean, create) : null;
} | #vulnerable code
public static <T> T getInstance(BeanManager beanManager, Class<T> beanClass, boolean create) {
return getInstance(beanManager, resolve(beanManager, beanClass), create);
}
#location 2
#vulnerability type NULL_DERE... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void encodeChildren(FacesContext context) throws IOException {
if (!TRUE.equals(getApplicationAttribute(context, Socket.class.getName()))) {
throw new IllegalStateException(ERROR_ENDPOINT_NOT_ENABLED);
}
String channel = getChannel();
if (channel =... | #vulnerable code
@Override
public void encodeChildren(FacesContext context) throws IOException {
if (!TRUE.equals(getApplicationAttribute(context, Socket.class.getName()))) {
throw new IllegalStateException(ERROR_ENDPOINT_NOT_ENABLED);
}
String channel = getChannel();
if (cha... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void apply(FaceletContext context, UIComponent parent) throws IOException {
if (!ComponentHandler.isNew(parent)) {
return;
}
if (!TRUE.equals(getApplicationAttribute(context.getFacesContext(), Socket.class.getName()))) {
throw new IllegalStateExcep... | #vulnerable code
@Override
public void apply(FaceletContext context, UIComponent parent) throws IOException {
if (!ComponentHandler.isNew(parent)) {
return;
}
if (!TRUE.equals(getApplicationAttribute(context.getFacesContext(), Socket.class.getName()))) {
throw new IllegalStat... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PreDestroyViewMapEvent) {
processPreDestroyView();
}
else if (event instanceof PostRestoreStateEvent && "unload".equals(getRequestParameter("omnifaces.event")))... | #vulnerable code
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PreDestroyViewMapEvent) {
BeanManager.INSTANCE.getReference(ViewScopeManager.class).preDestroyView();
}
}
#location 4
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Set<Future<Void>> send(Object message) {
return sessionManager.send(getChannelId(channel, sessionScopeIds, viewScopeIds), message);
} | #vulnerable code
@Override
public Set<Future<Void>> send(Object message) {
return SocketSessionManager.getInstance().send(getChannelId(channel, sessionScopeIds, viewScopeIds), message);
}
#location 3
#vulnerability type NULL_DER... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static InjectionPoint getCurrentInjectionPoint(BeanManager beanManager, CreationalContext<?> creationalContext) {
Bean<InjectionPointGenerator> bean = resolve(beanManager, InjectionPointGenerator.class);
return (bean != null) ? (InjectionPoint) beanManager.getInjectab... | #vulnerable code
public static InjectionPoint getCurrentInjectionPoint(BeanManager beanManager, CreationalContext<?> creationalContext) {
return (InjectionPoint) beanManager.getInjectableReference(
resolve(beanManager, InjectionPointGenerator.class).getInjectionPoints().iterator().nex... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void processAction(ActionEvent event) throws AbortProcessingException {
FacesContext context = FacesContext.getCurrentInstance();
PartialViewContext partialViewContext = context.getPartialViewContext();
if (partialViewContext.isAjaxRequest()) {
Collec... | #vulnerable code
@Override
public void processAction(ActionEvent event) throws AbortProcessingException {
FacesContext context = FacesContext.getCurrentInstance();
PartialViewContext partialViewContext = context.getPartialViewContext();
if (partialViewContext.isAjaxRequest()) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private TreeModel<T> getPreviousSibling(TreeModel<T> parent, int index) {
if (parent == null) {
return null;
}
else if (index >= 0) {
return parent.getChildren().get(index);
}
else {
TreeModel<T> previousParent = parent.getPreviousSibling();
return getPrevi... | #vulnerable code
private TreeModel<T> getPreviousSibling(TreeModel<T> parent, int index) {
if (isRoot()) {
return null;
}
else if (index >= 0) {
return parent.getChildren().get(index);
}
else {
TreeModel<T> previousParent = parent.getPreviousSibling();
return getPrevi... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void shouldBeAbleToConvertNumbers(){
assertThat(((Character) converter.convert("r", char.class, bundle)).charValue(), is(equalTo('r')));
} | #vulnerable code
@Test
public void shouldBeAbleToConvertNumbers(){
assertThat(((Character) converter.convert("r", char.class, errors, bundle)).charValue(), is(equalTo('r')));
}
#location 3
#vulnerability type NULL... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void prepareRemotingContainer() throws IOException, InterruptedException {
// if remoting container already exists, we reuse it
if (context.getRemotingContainer() != null) {
if (driver.hasContainer(localLauncher, context.getRemotingContaine... | #vulnerable code
public void prepareRemotingContainer() throws IOException, InterruptedException {
// if remoting container already exists, we reuse it
if (context.getRemotingContainer() != null) {
if (driver.hasContainer(localLauncher, context.getRemotingCo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void readerWriterTest() throws URISyntaxException, IOException, TransformationException, SAXException {
File file = new File(HTMLDocContentStructureConvertersTest.class.getResource(modelFilePath).toURI());
String expectedHTML = FileUtils.readF... | #vulnerable code
@Test
public void readerWriterTest() throws URISyntaxException, IOException, TransformationException, SAXException {
File file = new File(HTMLDocContentStructureConvertersTest.class.getResource(modelFilePath).toURI());
String expectedHTML = FileUtils... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public BxDocument getDocument() throws TransformationException {
InputStreamReader isr = null;
try {
isr = new InputStreamReader(inputStream, "UTF-8");
TrueVizToBxDocumentReader reader = new TrueVizToBxDocumentReader();
retu... | #vulnerable code
public BxDocument getDocument() throws TransformationException {
InputStreamReader isr = new InputStreamReader(inputStream);
TrueVizToBxDocumentReader reader = new TrueVizToBxDocumentReader();
return new BxDocument().setPages(reader.read(isr));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws AnalysisException, TransformationException, IOException {
// args[0] path to xml directory
if(args.length != 1) {
System.err.println("Source directory needed!");
System.exit(1);
}
SVMInitialZoneClassifier classifier ... | #vulnerable code
public static void main(String[] args) throws AnalysisException, TransformationException, IOException {
// args[0] path to xml directory
if(args.length != 1) {
System.err.println("Source directory needed!");
System.exit(1);
}
InputStreamReader modelISR = new ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws ParseException, IOException, TransformationException, AnalysisException, CloneNotSupportedException {
Options options = new Options();
options.addOption("under", false, "use undersampling for data selection");
... | #vulnerable code
public static void main(String[] args) throws ParseException, IOException, TransformationException, AnalysisException, CloneNotSupportedException {
Options options = new Options();
options.addOption("under", false, "use undersampling for data selection")... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void toLibSVM(List<TrainingElement<BxZoneLabel>> trainingElements, String filePath) throws IOException {
BufferedWriter svmDataFile = null;
try {
FileWriter fstream = new FileWriter(filePath);
svmDataFile = new BufferedWriter... | #vulnerable code
public static void toLibSVM(List<TrainingElement<BxZoneLabel>> trainingElements, String filePath) {
try {
FileWriter fstream = new FileWriter(filePath);
BufferedWriter svmDataFile = new BufferedWriter(fstream);
for (TrainingEl... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public List<BxDocument> getDocuments() throws TransformationException {
String dirPath = directory.getPath();
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
List<BxDocument> documents = new ArrayList<BxDocument>();
... | #vulnerable code
@Override
public List<BxDocument> getDocuments() throws TransformationException {
String dirPath = directory.getPath();
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
List<BxDocument> documents = new ArrayList<BxDocumen... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws ParseException, IOException, TransformationException, AnalysisException, CloneNotSupportedException {
Options options = new Options();
options.addOption("under", false, "use undersampling for data selection");
... | #vulnerable code
public static void main(String[] args) throws ParseException, IOException, TransformationException, AnalysisException {
Options options = new Options();
options.addOption("under", false, "use undersampling for data selection");
options.addOption(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static BxDocument getDocument(File file) throws IOException, TransformationException {
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
BxDocument newDoc = new BxDocument();
InputStream is = new FileInputStream(file);
... | #vulnerable code
public static BxDocument getDocument(File file) throws IOException, TransformationException {
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
BxDocument newDoc = new BxDocument();
InputStream is = new FileInputStream(file);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void loadModelFromFile(String modelFilePath, String rangeFilePath) throws IOException {
BufferedReader modelFile = new BufferedReader(new InputStreamReader(new FileInputStream(modelFilePath), "UTF-8"));
BufferedReader rangeFile = null;
if (range... | #vulnerable code
public void loadModelFromFile(String modelFilePath, String rangeFilePath) throws IOException {
BufferedReader modelFile = new BufferedReader(new InputStreamReader(new FileInputStream(modelFilePath)));
BufferedReader rangeFile = null;
if (rangeFil... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public List<BxDocument> getDocuments() throws TransformationException {
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
List<BxDocument> documents = new ArrayList<BxDocument>();
for (File file : FileUtils.listFiles(... | #vulnerable code
@Override
public List<BxDocument> getDocuments() throws TransformationException {
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
List<BxDocument> documents = new ArrayList<BxDocument>();
for (File file : FileUtils.list... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSegmentPages() throws TransformationException, AnalysisException, UnsupportedEncodingException {
Reader reader = new InputStreamReader(getResource("DocstrumPageSegmenter01.xml"), "UTF-8");
BxDocument inDoc = new BxDocument().setPages(... | #vulnerable code
@Test
public void testSegmentPages() throws TransformationException, AnalysisException {
Reader reader = new InputStreamReader(getResource("DocstrumPageSegmenter01.xml"));
BxDocument inDoc = new BxDocument().setPages(new TrueVizToBxDocumentReader().r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSegmentPages() throws TransformationException, AnalysisException, UnsupportedEncodingException {
Reader reader = new InputStreamReader(getResource("DocstrumPageSegmenter01.xml"), "UTF-8");
BxDocument inDoc = new BxDocument().setPages(... | #vulnerable code
@Test
public void testSegmentPages() throws TransformationException, AnalysisException {
Reader reader = new InputStreamReader(getResource("DocstrumPageSegmenter01.xml"));
BxDocument inDoc = new BxDocument().setPages(new TrueVizToBxDocumentReader().r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void loadModelFromResources(String modelFilePath, String rangeFilePath) throws IOException {
InputStreamReader modelISR = new InputStreamReader(SVMClassifier.class.getResourceAsStream(modelFilePath), "UTF-8");
BufferedReader modelFile = new BufferedRead... | #vulnerable code
public void loadModelFromResources(String modelFilePath, String rangeFilePath) throws IOException {
InputStreamReader modelISR = new InputStreamReader(SVMClassifier.class.getResourceAsStream(modelFilePath));
BufferedReader modelFile = new BufferedReader(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String getErrorMessage() {
String res;
if (error != null) {
res = error.getMessage();
if(res==null || res.isEmpty()) {
res = "Exception is: "+error.getClass().toString();
}
} else {
... | #vulnerable code
public String getErrorMessage() {
String res = "";
if (error != null) {
res = error.getMessage();
if(res==null || res.isEmpty()) {
res = "Exception is: "+res.getClass().toString();
}
} else {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testImporter() throws IOException, ParserConfigurationException, SAXException,
TransformationException {
BxPage page = new TrueVizToBxDocumentReader().read(new InputStreamReader(TrueVizToBxDocumentReaderTest.class.getResourceAsStream(... | #vulnerable code
@Test
public void testImporter() throws IOException, ParserConfigurationException, SAXException,
TransformationException {
BxPage page = new TrueVizToBxDocumentReader().read(new InputStreamReader(TrueVizToBxDocumentReaderTest.class.getResourceAsS... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void metadataExtractionTest() throws AnalysisException, JDOMException, IOException, SAXException, TransformationException, URISyntaxException {
InputStream expStream = AbstractBibReferenceExtractorTest.class.getResourceAsStream(EXP_FILE);
Buff... | #vulnerable code
@Test
public void metadataExtractionTest() throws AnalysisException, JDOMException, IOException, SAXException, TransformationException, URISyntaxException {
InputStream expStream = AbstractBibReferenceExtractorTest.class.getResourceAsStream(EXP_FILE);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public List<BxDocument> getDocuments() throws TransformationException {
List<BxDocument> documents = new ArrayList<BxDocument>();
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
Enumeration<? extends ZipEntry> entri... | #vulnerable code
@Override
public List<BxDocument> getDocuments() throws TransformationException {
List<BxDocument> documents = new ArrayList<BxDocument>();
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
Enumeration<? extends ZipEntry>... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws JDOMException, IOException, AnalysisException {
if (args.length != 3) {
System.err.println("USAGE: ReferenceParsingEvaluator <foldness> <model_path> <test_path>");
System.exit(1);
}
... | #vulnerable code
public static void main(String[] args) throws JDOMException, IOException, AnalysisException {
if (args.length != 3) {
System.err.println("USAGE: ReferenceParsingEvaluator <foldness> <model_path> <test_path>");
System.exit(1);
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void deepCloneTest() throws TransformationException, UnsupportedEncodingException {
InputStream stream = BxModelUtilsTest.class.getResourceAsStream(EXP_STR_LAB_1);
TrueVizToBxDocumentReader reader = new TrueVizToBxDocumentReader();
BxD... | #vulnerable code
@Test
public void deepCloneTest() throws TransformationException {
InputStream stream = BxModelUtilsTest.class.getResourceAsStream(EXP_STR_LAB_1);
TrueVizToBxDocumentReader reader = new TrueVizToBxDocumentReader();
BxDocument doc = new BxDocu... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void loadModelFromResources(String modelFilePath, String rangeFilePath) throws IOException
{
InputStreamReader modelISR = new InputStreamReader(this.getClass().getResourceAsStream(modelFilePath));
BufferedReader modelFile = new BufferedReader(modelISR);
InputStr... | #vulnerable code
public void loadModelFromResources(String modelFilePath, String rangeFilePath) throws IOException
{
InputStreamReader modelISR = new InputStreamReader(SVMClassifier.class
.getResourceAsStream(modelFilePath));
BufferedReader modelFile = new BufferedReader(modelISR)... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void loadModelFromResources(String modelFilePath, String rangeFilePath) throws IOException {
InputStreamReader modelISR = new InputStreamReader(SVMClassifier.class.getResourceAsStream(modelFilePath), "UTF-8");
BufferedReader modelFile = new BufferedRead... | #vulnerable code
public void loadModelFromResources(String modelFilePath, String rangeFilePath) throws IOException {
InputStreamReader modelISR = new InputStreamReader(SVMClassifier.class.getResourceAsStream(modelFilePath));
BufferedReader modelFile = new BufferedReader(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void loadModelFromFile(String modelFilePath, String rangeFilePath) throws IOException {
BufferedReader modelFile = new BufferedReader(new InputStreamReader(new FileInputStream(modelFilePath), "UTF-8"));
BufferedReader rangeFile = null;
if (range... | #vulnerable code
public void loadModelFromFile(String modelFilePath, String rangeFilePath) throws IOException {
BufferedReader modelFile = new BufferedReader(new InputStreamReader(new FileInputStream(modelFilePath)));
BufferedReader rangeFile = null;
if (rangeFil... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private BxDocument getDocumentFromZip(String filename) throws TransformationException, IOException {
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMo... | #vulnerable code
private BxDocument getDocumentFromZip(String filename) throws TransformationException, IOException {
TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws AnalysisException, TransformationException, IOException {
// args[0] path to xml directory
if(args.length != 1) {
System.err.println("Source directory needed!");
System.exit(1);
}
SVMInitialZoneClassifier classifier ... | #vulnerable code
public static void main(String[] args) throws AnalysisException, TransformationException, IOException {
// args[0] path to xml directory
if(args.length != 1) {
System.err.println("Source directory needed!");
System.exit(1);
}
InputStreamReader modelISR = new ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static String getFileSha1(File file) {
if (!file.isFile()) {
return null;
}
MessageDigest digest = null;
FileInputStream in = null;
byte[] buffer = new byte[8192];
int len;
try {
digest = M... | #vulnerable code
public static String getFileSha1(File file) {
if (!file.isFile()) {
return null;
}
MessageDigest digest = null;
FileInputStream in = null;
byte buffer[] = new byte[8192];
int len;
try {
dige... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void writeToXml() throws Exception {
// 排版缩进的格式
OutputFormat format = OutputFormat.createPrettyPrint();
// 设置编码
format.setEncoding("UTF-8");
// 创建XMLWriter对象,指定了写出文件及编码格式
XMLWriter writer = null;
writer = new XMLW... | #vulnerable code
public void writeToXml() throws Exception {
// 排版缩进的格式
OutputFormat format = OutputFormat.createPrettyPrint();
// 设置编码
format.setEncoding("UTF-8");
// 创建XMLWriter对象,指定了写出文件及编码格式
XMLWriter writer = null;
writer = ne... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
GitHub(String apiUrl, String login, String oauthAccessToken, String jwtToken, String password,
HttpConnector connector, RateLimitHandler rateLimitHandler, AbuseLimitHandler abuseLimitHandler)
throws IOException {
if (apiUrl.endsWith("/"))
... | #vulnerable code
<T extends GHMetaExamples.GHMetaExample> GHMetaExamples.GHMetaExample getMetaExample(Class<T> clazz)
throws IOException {
return retrieve().to("/meta", clazz);
}
#location 3
#vulnerability... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected String getApiRoute() {
if (owner == null) {
// Issues returned from search to do not have an owner. Attempt to use url.
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
return String... | #vulnerable code
@Override
protected String getApiRoute() {
if (owner == null) {
// Issues returned from search to do not have an owner. Attempt to use url.
return StringUtils.prependIfMissing(getUrl().toString().replace(root.getApiUrl(), ""), "/");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public <T> T to(URL url, Class<T> type) throws IOException {
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
uc.setDoOutput(true);
uc.setRequestProperty("Content-type","application/x-www-form-urlencoded");
uc.setRequestMethod(... | #vulnerable code
public <T> T to(URL url, Class<T> type) throws IOException {
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
uc.setDoOutput(true);
uc.setRequestProperty("Content-type","application/x-www-form-urlencoded");
uc.setRequestM... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected String getIssuesApiRoute() {
if (owner == null) {
// Issues returned from search to do not have an owner. Attempt to use url.
final URL url = Objects.requireNonNull(getUrl(), "Missing instance URL!");
return StringUtils.pr... | #vulnerable code
protected String getIssuesApiRoute() {
if (owner == null) {
// Issues returned from search to do not have an owner. Attempt to use url.
return StringUtils.prependIfMissing(getUrl().toString().replace(root.getApiUrl(), ""), "/");
}... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
static PagedIterable<GHDiscussion> readAll(GHTeam team) throws IOException {
return team.root.createRequest()
.setRawUrlPath(getRawUrlPath(team, null))
.toIterable(GHDiscussion[].class, item -> item.wrapUp(team));
} | #vulnerable code
static PagedIterable<GHDiscussion> readAll(GHTeam team) throws IOException {
return team.root.createRequest()
.setRawUrlPath(team.getUrl().toString() + "/discussions")
.toIterable(GHDiscussion[].class, item -> item.wrapUp(team));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
static GHDiscussion read(GHTeam team, long discussionNumber) throws IOException {
return team.root.createRequest()
.setRawUrlPath(getRawUrlPath(team, discussionNumber))
.fetch(GHDiscussion.class)
.wrapUp(team);
} | #vulnerable code
static GHDiscussion read(GHTeam team, long discussionNumber) throws IOException {
return team.root.createRequest()
.setRawUrlPath(team.getUrl().toString() + "/discussions/" + discussionNumber)
.fetch(GHDiscussion.class)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void delete() throws IOException {
team.root.createRequest().method("DELETE").setRawUrlPath(getRawUrlPath(team, number)).send();
} | #vulnerable code
public void delete() throws IOException {
team.root.createRequest()
.method("DELETE")
.setRawUrlPath(team.getUrl().toString() + "/discussions/" + number)
.send();
}
#location 4
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public <T> T to(URL url, Class<T> type) throws IOException {
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
uc.setDoOutput(true);
uc.setRequestProperty("Content-type","application/x-www-form-urlencoded");
uc.setRequestMethod(... | #vulnerable code
public <T> T to(URL url, Class<T> type) throws IOException {
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
uc.setDoOutput(true);
uc.setRequestProperty("Content-type","application/x-www-form-urlencoded");
uc.setRequestM... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testWindowPeer() throws Exception {
if (Platform.isMacOSX() ||
System.getProperty("java.version").matches("1\\.6\\..*")) {
// Oracle Java and jawt: it's complicated.
// See http://forum.lwjgl.org/index.php?topic=4326.0
// OpenJDK ... | #vulnerable code
@Test
public void testWindowPeer() throws Exception {
if (Platform.isMacOSX() ||
System.getProperty("java.version)").matches("1\\.6\\..*")) {
// Oracle Java and jawt: it's complicated.
// See http://forum.lwjgl.org/index.php?topic=4326.0
// O... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private HttpClient getHttpClient(PrintStream logger) throws Exception {
boolean ignoreUnverifiedSSL = ignoreUnverifiedSSLPeer;
String stashServer = stashServerBaseUrl;
DescriptorImpl descriptor = getDescriptor();
if ("".equals(stashServer) || stas... | #vulnerable code
private HttpClient getHttpClient(PrintStream logger) {
HttpClient client = null;
boolean ignoreUnverifiedSSL = ignoreUnverifiedSSLPeer;
String url = stashServerBaseUrl;
DescriptorImpl descriptor = getDescriptor();
if ("".equals(url) || url... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) {
AppUtil appUtil = new AppUtil();
AService service = (AService) appUtil.getComponentInstance("aService");
AggregateRootA aggregateRootA = service.getAggregateRootA("11");
DomainMessage res = service.commandA("11", aggregateRootA, 1... | #vulnerable code
public static void main(String[] args) {
AppUtil appUtil = new AppUtil();
AService service = (AService) appUtil.getComponentInstance("aService");
AggregateRootA aggregateRootA = service.getAggregateRootA("11");
DomainMessage res = service.commandA("11", aggregateRo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean doExists(String name, Locale locale, String path) throws Exception {
if (file != null && file.exists()) {
ZipFile zipFile = new ZipFile(file);
try {
return zipFile.getEntry(name) != null;
} finally {
zipFile.close();
}
}
return false;
} | #vulnerable code
public boolean doExists(String name, Locale locale, String path) throws Exception {
return file != null && file.exists() && new ZipFile(file).getEntry(name) != null;
}
#location 2
#vulnerability type RESOURCE_LEA... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public long getLastModified() {
try {
JarFile jarFile = new JarFile(file);
return jarFile.getEntry(getName()).getTime();
} catch (Throwable e) {
return super.getLastModified();
}
} | #vulnerable code
public long getLastModified() {
try {
JarFile zipFile = new JarFile(file);
return zipFile.getEntry(getName()).getTime();
} catch (Throwable e) {
return super.getLastModified();
}
}
#location 4
#vulne... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public Template extend(String name, Locale locale, String encoding) throws IOException, ParseException {
if (name == null || name.length() == 0) {
throw new IllegalArgumentException("include template name == null");
}
String macro = null;
in... | #vulnerable code
public Template extend(String name, Locale locale, String encoding) throws IOException, ParseException {
if (name == null || name.length() == 0) {
throw new IllegalArgumentException("include template name == null");
}
String macro = null... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public Template parse(String name, String encoding) throws IOException, ParseException {
if (name == null || name.length() == 0) {
throw new IllegalArgumentException("include template name == null");
}
String macro = null;
int i = name.in... | #vulnerable code
public Template parse(String name, String encoding) throws IOException, ParseException {
if (name == null || name.length() == 0) {
throw new IllegalArgumentException("include template name == null");
}
String macro = null;
int i = n... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean doExists(String name, Locale locale, String path) throws Exception {
if (file != null && file.exists()) {
JarFile jarFile = new JarFile(file);
try {
return jarFile.getEntry(name) != null;
} finally {
jarFile.close();
}
}
return false;
} | #vulnerable code
public boolean doExists(String name, Locale locale, String path) throws Exception {
return file != null && file.exists() && new JarFile(file).getEntry(name) != null;
}
#location 2
#vulnerability type RESOURCE_LEA... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static Object decodeToObject(
String encodedObject, int options, final ClassLoader loader )
throws java.io.IOException, java.lang.ClassNotFoundException {
// Decode and gunzip if necessary
byte[] objBytes = decode( encodedObject, optio... | #vulnerable code
public static Object decodeToObject(
String encodedObject, int options, final ClassLoader loader )
throws java.io.IOException, java.lang.ClassNotFoundException {
// Decode and gunzip if necessary
byte[] objBytes = decode( encodedObject,... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testException() throws Exception {
boolean profile = "true".equals(System.getProperty("profile"));
Engine engine = Engine.getEngine("httl-exception.properties");
String dir = engine.getProperty("template.directory", "");
if (dir.length() > 0 && dir.sta... | #vulnerable code
@Test
public void testException() throws Exception {
boolean profile = "true".equals(System.getProperty("profile"));
if (! profile)
System.out.println("========httl-exception.properties========");
Engine engine = Engine.getEngine("httl-exception.properties");
S... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public long getLength() {
try {
JarFile jarFile = new JarFile(file);
try {
return jarFile.getEntry(getName()).getSize();
} finally {
jarFile.close();
}
} catch (IOException e) {
return super.getLength();
}
} | #vulnerable code
public long getLength() {
try {
JarFile jarFile = new JarFile(file);
return jarFile.getEntry(getName()).getSize();
} catch (IOException e) {
return super.getLength();
}
}
#location 4
#vulnerability t... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void setServletContext(ServletContext servletContext) {
if (servletContext == null) {
return;
}
if (ServletLoader.getServletContext() == null) {
ServletLoader.setServletContext(servletContext);
}
if (ENGINE == null) {
synchronized (WebEngine.clas... | #vulnerable code
public static void setServletContext(ServletContext servletContext) {
if (servletContext == null) {
return;
}
if (ServletLoader.getServletContext() == null) {
ServletLoader.setServletContext(servletContext);
}
if (ENGINE == null) {
synchronized (WebEngin... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static String encodeObject( java.io.Serializable serializableObject, int options )
throws java.io.IOException {
if( serializableObject == null ){
throw new NullPointerException( "Cannot serialize a null object." );
} // end if: null
... | #vulnerable code
public static String encodeObject( java.io.Serializable serializableObject, int options )
throws java.io.IOException {
if( serializableObject == null ){
throw new NullPointerException( "Cannot serialize a null object." );
} // end if: ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private static String getRefValue(Properties result, String v) {
while (v != null && v.startsWith(REF)) {
String ref = v.substring(1);
v = result.getProperty(ref);
if (v == null) {
v = System.getProperty(ref);
}
}
return v == null ? "" : v;
} | #vulnerable code
private static String getRefValue(Properties result, String v) {
if (v != null) {
while (v.startsWith(REF)) {
String ref = v.substring(1);
v = result.getProperty(ref);
if (v == null) {
v = System.getProperty(ref);
}
}
}
return v == null ? "... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public long getLength() {
try {
ZipFile zipFile = new ZipFile(file);
try {
return zipFile.getEntry(getName()).getSize();
} finally {
zipFile.close();
}
} catch (IOException e) {
return super.getLength();
}
} | #vulnerable code
public long getLength() {
try {
ZipFile zipFile = new ZipFile(file);
return zipFile.getEntry(getName()).getSize();
} catch (IOException e) {
return super.getLength();
}
}
#location 4
#vulnerability t... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void setServletContext(ServletContext servletContext) {
if (servletContext == null) {
return;
}
if (ServletLoader.getServletContext() == null) {
ServletLoader.setServletContext(servletContext);
}
if (ENGINE == null) {
synchronized (WebEngine.clas... | #vulnerable code
public static void setServletContext(ServletContext servletContext) {
if (servletContext == null) {
return;
}
if (ServletLoader.getServletContext() == null) {
ServletLoader.setServletContext(servletContext);
}
if (ENGINE == null) {
synchronized (WebEngin... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static byte[] decode( String s, int options ) throws java.io.IOException {
if( s == null ){
throw new NullPointerException( "Input string was null." );
} // end if
byte[] bytes;
try {
bytes = s... | #vulnerable code
public static byte[] decode( String s, int options ) throws java.io.IOException {
if( s == null ){
throw new NullPointerException( "Input string was null." );
} // end if
byte[] bytes;
try {
byt... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean doExists(String name, Locale locale, String path) throws Exception {
InputStream in = new URL(path).openStream();
try {
return in != null;
} finally {
if (in != null)
in.close();
}
} | #vulnerable code
public boolean doExists(String name, Locale locale, String path) throws Exception {
InputStream in = new URL(path).openStream();
try {
return in != null;
} finally {
in.close();
}
}
#location 6
#vulne... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void init() {
defaultFilterVariable = "$" + filterVariable;
defaultFormatterVariable = "$" + formatterVariable;
if (importVariables != null && importVariables.length > 0) {
this.importTypes = new HashMap<String, Class<?>>();
for (String var : importVariables) ... | #vulnerable code
public void init() {
defaultFilterVariable = "$" + filterVariable;
defaultFormatterVariable = "$" + formatterVariable;
if (importVariables != null && importVariables.length > 0) {
this.importTypes = new HashMap<String, Class<?>>();
for (String var : importVaria... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static Object parseXbean(String xml) {
if (xml == null) {
return null;
}
ByteArrayInputStream bi = new ByteArrayInputStream(xml.getBytes());
XMLDecoder xd = new XMLDecoder(bi);
try {
return xd.readObject();
} finally {
xd.close();
}
} | #vulnerable code
public static Object parseXbean(String xml) {
if (xml == null) {
return null;
}
ByteArrayInputStream bi = new ByteArrayInputStream(xml.getBytes());
XMLDecoder xd = new XMLDecoder(bi);
return xd.readObject();
}
#location 7
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static byte[] encodeBytesToBytes( byte[] source, int off, int len, int options ) throws java.io.IOException {
if( source == null ){
throw new NullPointerException( "Cannot serialize a null array." );
} // end if: null
if( off < 0... | #vulnerable code
public static byte[] encodeBytesToBytes( byte[] source, int off, int len, int options ) throws java.io.IOException {
if( source == null ){
throw new NullPointerException( "Cannot serialize a null array." );
} // end if: null
if( o... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void init() {
if (importVariables != null && importVariables.length > 0) {
this.importTypes = new HashMap<String, Class<?>>();
for (String var : importVariables) {
int i = var.lastIndexOf(' ');
if (i < 0) {
throw new IllegalArgumentException("Illegal ... | #vulnerable code
public void init() {
if (importVariables != null && importVariables.length > 0) {
this.importTypes = new HashMap<String, Class<?>>();
for (String var : importVariables) {
int i = var.lastIndexOf(' ');
if (i < 0) {
throw new IllegalArgumentException("Il... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public InputStream getInputStream() throws IOException {
// 注:JarFile与File的设计是不一样的,File相当于C#的FileInfo,只持有信息,
// 而JarFile构造时即打开流,所以每次读取数据时,重新new新的实例,而不作为属性字段持有。
JarFile jarFile = new JarFile(file);
return jarFile.getInputStream(jarFile.getEntry(getName()));
} | #vulnerable code
public InputStream getInputStream() throws IOException {
// 注:JarFile与File的设计是不一样的,File相当于C#的FileInfo,只持有信息,
// 而JarFile构造时即打开流,所以每次读取数据时,重新new新的实例,而不作为属性字段持有。
JarFile zipFile = new JarFile(file);
return zipFile.getInputStream(zipFile.getEntry(getName()));
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testNoProcessorWroManagerFactory() throws IOException {
final WroManagerFactory factory = new ServletContextAwareWroManagerFactory();
manager = factory.getInstance();
manager.setModelFactory(getValidModelFactory());
final HttpServletRequest r... | #vulnerable code
@Test
public void testNoProcessorWroManagerFactory() throws IOException {
final WroManagerFactory factory = new ServletContextAwareWroManagerFactory();
manager = factory.getInstance();
manager.setModelFactory(getValidModelFactory());
final HttpServletReq... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void process(final Resource resource, final Reader reader, final Writer writer)
throws IOException {
try {
// using ReaderInputStream instead of ByteArrayInputStream, cause processing to freeze
final String encoding = Context.get().getConfig().getEn... | #vulnerable code
public void process(final Resource resource, final Reader reader, final Writer writer)
throws IOException {
try {
System.out.println("BOM:");
// using ReaderInputStream instead of ByteArrayInputStream, cause processing to freeze
final InputStre... | 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.