#vulnerable code 
                             @Override
	protected void processInput(String input) throws SteamException {

		if (input.equals("stats request")) {
			userStats.requestCurrentStats();
		} else if (input.equals("stats store")) {
			userStats.storeStats();
		} else if (input.equals("file list")) {
			int numFiles = remoteStorage.getFileCount();
			System.out.println("Num of files: " + numFiles);

			for (int i = 0; i < numFiles; i++) {
				int[] sizes = new int[1];
				String name = remoteStorage.getFileNameAndSize(i, sizes);
				boolean exists = remoteStorage.fileExists(name);
				System.out.println("# " + i + " : name=" + name + ", size=" + sizes[0] + ", exists=" + (exists ? "yes" : "no"));
			}
		} else if (input.startsWith("file write ")) {
			String path = input.substring("file write ".length());
			File file = new File(path);
			try {
				FileInputStream in = new FileInputStream(file);
				SteamUGCFileWriteStreamHandle remoteFile = remoteStorage.fileWriteStreamOpen(path);
				if (remoteFile != null) {
					byte[] bytes = new byte[1024];
					int bytesRead;
					while((bytesRead = in.read(bytes, 0, bytes.length)) > 0) {
						ByteBuffer buffer = ByteBuffer.allocateDirect(bytesRead);
						buffer.put(bytes, 0, bytesRead);
						remoteStorage.fileWriteStreamWriteChunk(remoteFile, buffer, buffer.limit());
					}
					remoteStorage.fileWriteStreamClose(remoteFile);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		} else if (input.startsWith("file delete ")) {
			String path = input.substring("file delete ".length());
			if (remoteStorage.fileDelete(path)) {
				System.out.println("deleted file '" + path + "'");
			}
		} else if (input.startsWith("file share ")) {
			remoteStorage.fileShare(input.substring("file share ".length()));
		} else if (input.startsWith("file publish ")) {
			String[] paths = input.substring("file publish ".length()).split(" ");
			if (paths.length >= 2) {
				System.out.println("publishing file: " + paths[0] + ", preview file: " + paths[1]);
				remoteStorage.publishWorkshopFile(paths[0], paths[1], utils.getAppID(),
						"Test UGC!", "Dummy UGC file published by test application.",
						SteamRemoteStorage.PublishedFileVisibility.Private, null,
						SteamRemoteStorage.WorkshopFileType.Community);
			}
		} else if (input.startsWith("file republish ")) {
			String[] paths = input.substring("file republish ".length()).split(" ");
			if (paths.length >= 3) {
				System.out.println("republishing id: " + paths[0] + ", file: " + paths[1] + ", preview file: " + paths[2]);

				SteamPublishedFileID fileID = new SteamPublishedFileID(Long.parseLong(paths[0]));

				SteamPublishedFileUpdateHandle updateHandle = remoteStorage.createPublishedFileUpdateRequest(fileID);
				if (updateHandle != null) {
					remoteStorage.updatePublishedFileFile(updateHandle, paths[1]);
					remoteStorage.updatePublishedFilePreviewFile(updateHandle, paths[2]);
					remoteStorage.updatePublishedFileTitle(updateHandle, "Updated Test UGC!");
					remoteStorage.updatePublishedFileDescription(updateHandle, "Dummy UGC file *updated* by test application.");
					remoteStorage.commitPublishedFileUpdate(updateHandle);
				}
			}
		} else if (input.equals("ugc query")) {
			SteamUGCQuery query = ugc.createQueryUserUGCRequest(user.getSteamID().getAccountID(), SteamUGC.UserUGCList.Subscribed,
					SteamUGC.MatchingUGCType.UsableInGame, SteamUGC.UserUGCListSortOrder.TitleAsc,
					utils.getAppID(), utils.getAppID(), 1);

			if (query.isValid()) {
				System.out.println("sending UGC query: " + query.toString());
				//ugc.setReturnTotalOnly(query, true);
				ugc.sendQueryUGCRequest(query);
			}
		} else if (input.startsWith("ugc download ")) {
			String name = input.substring("ugc download ".length());
			SteamUGCHandle handle = new SteamUGCHandle(Long.parseLong(name, 16));
			remoteStorage.ugcDownload(handle, 0);
		} else if (input.startsWith("ugc subscribe ")) {
			Long id = Long.parseLong(input.substring("ugc subscribe ".length()), 16);
			ugc.subscribeItem(new SteamPublishedFileID(id));
		} else if (input.startsWith("ugc unsubscribe ")) {
			Long id = Long.parseLong(input.substring("ugc unsubscribe ".length()), 16);
			ugc.unsubscribeItem(new SteamPublishedFileID(id));
		} else if (input.startsWith("ugc state ")) {
			Long id = Long.parseLong(input.substring("ugc state ".length()), 16);
			Collection<SteamUGC.ItemState> itemStates = ugc.getItemState(new SteamPublishedFileID(id));
			System.out.println("UGC item states: " + itemStates.size());
			for (SteamUGC.ItemState itemState : itemStates) {
				System.out.println("  " + itemState.name());
			}
		} else if (input.startsWith("ugc details ")) {
			System.out.println("requesting UGC details (deprecated API call)");
			Long id = Long.parseLong(input.substring("ugc details ".length()), 16);
			ugc.requestUGCDetails(new SteamPublishedFileID(id), 0);

			SteamUGCQuery query = ugc.createQueryUGCDetailsRequest(new SteamPublishedFileID(id));
			if (query.isValid()) {
				System.out.println("sending UGC details query: " + query.toString());
				ugc.sendQueryUGCRequest(query);
			}
		} else if (input.startsWith("ugc info ")) {
			Long id = Long.parseLong(input.substring("ugc info ".length()), 16);
			SteamUGC.ItemInstallInfo installInfo = new SteamUGC.ItemInstallInfo();
			if (ugc.getItemInstallInfo(new SteamPublishedFileID(id), installInfo)) {
				System.out.println("  folder: " + installInfo.getFolder());
				System.out.println("  size on disk: " + installInfo.getSizeOnDisk());
			}
			SteamUGC.ItemDownloadInfo downloadInfo = new SteamUGC.ItemDownloadInfo();
			if (ugc.getItemDownloadInfo(new SteamPublishedFileID(id), downloadInfo)) {
				System.out.println("  bytes downloaded: " + downloadInfo.getBytesDownloaded());
				System.out.println("  bytes total: " + downloadInfo.getBytesTotal());
			}
		} else if (input.startsWith("leaderboard find ")) {
			String name = input.substring("leaderboard find ".length());
			userStats.findLeaderboard(name);
		} else if (input.startsWith("leaderboard list ")) {
			String[] params = input.substring("leaderboard list ".length()).split(" ");
			if (currentLeaderboard != null && params.length >= 2) {
				userStats.downloadLeaderboardEntries(currentLeaderboard,
						SteamUserStats.LeaderboardDataRequest.Global,
						Integer.valueOf(params[0]), Integer.valueOf(params[1]));
			}
		} else if (input.startsWith("leaderboard score ")) {
			String score = input.substring("leaderboard score ".length());
			if (currentLeaderboard != null) {
				System.out.println("uploading score " + score + " to leaderboard " + currentLeaderboard.toString());
				userStats.uploadLeaderboardScore(currentLeaderboard,
						SteamUserStats.LeaderboardUploadScoreMethod.KeepBest, Integer.valueOf(score));
			}
		} else if (input.startsWith("apps subscribed ")) {
			String appId = input.substring("apps subscribed ".length());
			boolean subscribed = apps.isSubscribedApp(Long.parseLong(appId));
			System.out.println("user described to app #" + appId + ": " + (subscribed ? "yes" : "no"));
		}

	} 
                            #location 34 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                             @Override
	protected void processInput(String input) throws SteamException {

		if (input.equals("stats request")) {
			userStats.requestCurrentStats();
		} else if (input.equals("stats store")) {
			userStats.storeStats();
		} else if (input.startsWith("achievement set ")) {
			String achievementName = input.substring("achievement set ".length());
			System.out.println("- setting " + achievementName + " to 'achieved'");
			userStats.setAchievement(achievementName);
		} else if (input.startsWith("achievement clear ")) {
			String achievementName = input.substring("achievement clear ".length());
			System.out.println("- clearing " + achievementName);
			userStats.clearAchievement(achievementName);
		} else if (input.equals("file list")) {
			int numFiles = remoteStorage.getFileCount();
			System.out.println("Num of files: " + numFiles);

			for (int i = 0; i < numFiles; i++) {
				int[] sizes = new int[1];
				String name = remoteStorage.getFileNameAndSize(i, sizes);
				boolean exists = remoteStorage.fileExists(name);
				System.out.println("# " + i + " : name=" + name + ", size=" + sizes[0] + ", exists=" + (exists ? "yes" : "no"));
			}
		} else if (input.startsWith("file write ")) {
			String path = input.substring("file write ".length());
			File file = new File(path);
			try {
				FileInputStream in = new FileInputStream(file);
				SteamUGCFileWriteStreamHandle remoteFile = remoteStorage.fileWriteStreamOpen(path);
				if (remoteFile != null) {
					byte[] bytes = new byte[1024];
					int bytesRead;
					while((bytesRead = in.read(bytes, 0, bytes.length)) > 0) {
						ByteBuffer buffer = ByteBuffer.allocateDirect(bytesRead);
						buffer.put(bytes, 0, bytesRead);
						remoteStorage.fileWriteStreamWriteChunk(remoteFile, buffer, buffer.limit());
					}
					remoteStorage.fileWriteStreamClose(remoteFile);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		} else if (input.startsWith("file delete ")) {
			String path = input.substring("file delete ".length());
			if (remoteStorage.fileDelete(path)) {
				System.out.println("deleted file '" + path + "'");
			}
		} else if (input.startsWith("file share ")) {
			remoteStorage.fileShare(input.substring("file share ".length()));
		} else if (input.startsWith("file publish ")) {
			String[] paths = input.substring("file publish ".length()).split(" ");
			if (paths.length >= 2) {
				System.out.println("publishing file: " + paths[0] + ", preview file: " + paths[1]);
				remoteStorage.publishWorkshopFile(paths[0], paths[1], utils.getAppID(),
						"Test UGC!", "Dummy UGC file published by test application.",
						SteamRemoteStorage.PublishedFileVisibility.Private, null,
						SteamRemoteStorage.WorkshopFileType.Community);
			}
		} else if (input.startsWith("file republish ")) {
			String[] paths = input.substring("file republish ".length()).split(" ");
			if (paths.length >= 3) {
				System.out.println("republishing id: " + paths[0] + ", file: " + paths[1] + ", preview file: " + paths[2]);

				SteamPublishedFileID fileID = new SteamPublishedFileID(Long.parseLong(paths[0]));

				SteamPublishedFileUpdateHandle updateHandle = remoteStorage.createPublishedFileUpdateRequest(fileID);
				if (updateHandle != null) {
					remoteStorage.updatePublishedFileFile(updateHandle, paths[1]);
					remoteStorage.updatePublishedFilePreviewFile(updateHandle, paths[2]);
					remoteStorage.updatePublishedFileTitle(updateHandle, "Updated Test UGC!");
					remoteStorage.updatePublishedFileDescription(updateHandle, "Dummy UGC file *updated* by test application.");
					remoteStorage.commitPublishedFileUpdate(updateHandle);
				}
			}
		} else if (input.equals("ugc query")) {
			SteamUGCQuery query = ugc.createQueryUserUGCRequest(user.getSteamID().getAccountID(), SteamUGC.UserUGCList.Subscribed,
					SteamUGC.MatchingUGCType.UsableInGame, SteamUGC.UserUGCListSortOrder.TitleAsc,
					utils.getAppID(), utils.getAppID(), 1);

			if (query.isValid()) {
				System.out.println("sending UGC query: " + query.toString());
				//ugc.setReturnTotalOnly(query, true);
				ugc.sendQueryUGCRequest(query);
			}
		} else if (input.startsWith("ugc download ")) {
			String name = input.substring("ugc download ".length());
			SteamUGCHandle handle = new SteamUGCHandle(Long.parseLong(name, 16));
			remoteStorage.ugcDownload(handle, 0);
		} else if (input.startsWith("ugc subscribe ")) {
			Long id = Long.parseLong(input.substring("ugc subscribe ".length()), 16);
			ugc.subscribeItem(new SteamPublishedFileID(id));
		} else if (input.startsWith("ugc unsubscribe ")) {
			Long id = Long.parseLong(input.substring("ugc unsubscribe ".length()), 16);
			ugc.unsubscribeItem(new SteamPublishedFileID(id));
		} else if (input.startsWith("ugc state ")) {
			Long id = Long.parseLong(input.substring("ugc state ".length()), 16);
			Collection<SteamUGC.ItemState> itemStates = ugc.getItemState(new SteamPublishedFileID(id));
			System.out.println("UGC item states: " + itemStates.size());
			for (SteamUGC.ItemState itemState : itemStates) {
				System.out.println("  " + itemState.name());
			}
		} else if (input.startsWith("ugc details ")) {
			System.out.println("requesting UGC details (deprecated API call)");
			Long id = Long.parseLong(input.substring("ugc details ".length()), 16);
			ugc.requestUGCDetails(new SteamPublishedFileID(id), 0);

			SteamUGCQuery query = ugc.createQueryUGCDetailsRequest(new SteamPublishedFileID(id));
			if (query.isValid()) {
				System.out.println("sending UGC details query: " + query.toString());
				ugc.sendQueryUGCRequest(query);
			}
		} else if (input.startsWith("ugc info ")) {
			Long id = Long.parseLong(input.substring("ugc info ".length()), 16);
			SteamUGC.ItemInstallInfo installInfo = new SteamUGC.ItemInstallInfo();
			if (ugc.getItemInstallInfo(new SteamPublishedFileID(id), installInfo)) {
				System.out.println("  folder: " + installInfo.getFolder());
				System.out.println("  size on disk: " + installInfo.getSizeOnDisk());
			}
			SteamUGC.ItemDownloadInfo downloadInfo = new SteamUGC.ItemDownloadInfo();
			if (ugc.getItemDownloadInfo(new SteamPublishedFileID(id), downloadInfo)) {
				System.out.println("  bytes downloaded: " + downloadInfo.getBytesDownloaded());
				System.out.println("  bytes total: " + downloadInfo.getBytesTotal());
			}
		} else if (input.startsWith("leaderboard find ")) {
			String name = input.substring("leaderboard find ".length());
			userStats.findLeaderboard(name);
		} else if (input.startsWith("leaderboard list ")) {
			String[] params = input.substring("leaderboard list ".length()).split(" ");
			if (currentLeaderboard != null && params.length >= 2) {
				userStats.downloadLeaderboardEntries(currentLeaderboard,
						SteamUserStats.LeaderboardDataRequest.Global,
						Integer.valueOf(params[0]), Integer.valueOf(params[1]));
			}
		} else if (input.startsWith("leaderboard score ")) {
			String score = input.substring("leaderboard score ".length());
			if (currentLeaderboard != null) {
				System.out.println("uploading score " + score + " to leaderboard " + currentLeaderboard.toString());
				userStats.uploadLeaderboardScore(currentLeaderboard,
						SteamUserStats.LeaderboardUploadScoreMethod.KeepBest, Integer.valueOf(score));
			}
		} else if (input.startsWith("apps subscribed ")) {
			String appId = input.substring("apps subscribed ".length());
			boolean subscribed = apps.isSubscribedApp(Long.parseLong(appId));
			System.out.println("user described to app #" + appId + ": " + (subscribed ? "yes" : "no"));
		}

	}