Should I write custom allocators for STL containers to interface with my memory pool, or just overwrite the standard new and delete

I want to write a custom memory allocator for learning. I’m tempted to have a master allocator that requests n bytes of ram from the heap (via new). This would be followed by several allocator… Adaptors? Each would interface with the master, requesting a block of memory to manage, these would be stack, linear, pool, slab allocators etc.

The problem I have is whether I should write custom allocator_traits to interface with these for the various STL containers; or if I should just ignore the adaptor idea and simply overload new and delete to use a custom pool allocator.

What I’m interested in understanding is what tangible benefit I would gain from having separate allocators for STL containers? It seems like the default std::allocator calls new and delete as needed so if I overload those to instead request from my big custom memory pool, I’d get all the benefit without the kruft of custom std::allocator code.

Or is this a matter where certain types of allocator models, like using a stack allocator for a std::dqueue would work better than the default allocator? And if so, wouldn’t the normal stl implementation already specialise?

Is there a way to add new div class via a theme’s Additional CSS interface?

I am trying to modify a woocommerce website and I have very little HTML/CSS training. Most of what I’ve learned has come from trial and error, some online tutorials, playing around with the developer console in Chrome, etc….

I’m trying to add an image border to the top of a page header right before an area called tg-container. I was able to put one below it, using an existing class, whose info I didn’t need to see. Can it be done with the Additional CSS interface built into the theme or do I have to go into the style.css and html to create the boarder? I know the benefit of the Additional CSS interface is having no need to edit the theme files directly whenever the theme is updated.

Bypass Page

Example Page with border – accessible only after bypass page is visited

IMAGE: Example page with Chrome Developer Console open and showing code for area

How to prevent configuration of Public IP on an interface

I have recently identified a security risk with some of the machines (primarily Windows 10 and MacOS laptops) my company issues to users. Specifically, a small subset of the users are regularly placing their device “directly on the Internet” when working remotely.

I suspect that this is primarily caused by plugging the Ethernet of the machine directly into a cable/DSL modem provided by the ISP for their home Internet connection. And that ISP is issuing a public IP address to our machine when it makes a DHCP request. This has publically exposed RDP, SSH, and other remote services only meant to be accessible from LAN networks.

The people/process solution to this problem will be user education, and I do intend to pursue this route. However, this will always be purely reactive–waiting for users to plug in to the Internet and chasing them down to ask them to stop doing so. I am currently only able to run periodic search queries to find these machines and would not seem to have a way to get automated, immediate alerting when it occurs.

I am wondering if there could be a more proactive, technical solution to this problem. I think that the ideal solution would be one that (a) prevents the configuration of a public IP address onto any of the NICs, especially via DHCP; (b) provides a pop-up message to the user informing them of what has occurred and whom to contact for assistance (i.e., our corporate help desk); and (c) immediately alerts our support staff that this has occurred, if possible.

The machines have various endpoint agents and technologies in place for management, including GPO policies, SCCM, and CrowdStrike. I do not have enough experience with any of these tools to know if it is feasible to create a technical solution using one of them, and I am not personally an administrator of any of these tools in my environment.

I have not yet attempted any particular implementation. It is within my skill set to create a Python script/executable that could check the configured IP addresses every X number of minutes; give the user a pop-up message; remove/change any public IP addresses; and/or possibly send back an alert. However, I’m highly doubtful that I could get approval to deploy this.

I certainly do not have the skill to create a full-time, inline monitoring/blocking agent, so the truly desired implementation would have to come from an existing tool. Is anybody aware of whether GPO, CrowdStrike, or other common endpoint management tools might be able to accomplish this technical solution?

Further, does anybody have any other guidance (people, process, or technology) that they feel might be useful in addressing this risk?

QuickSort – List Interface Java

Yes, this is one of my assignments.

Question:

I am asked to rewrite a generic QuickSort algorithm using only Java List Interface. The purpose is that the algorithm can be executed for both LinkedList and ArrayList with any type extends Comparable interface. Professor suggests me that I should think stackwise and list approach (instead of in-place approach), using as less memory as possible and still maintain O(nlogn) complexity.

What I got so far

I have these lists lessThanPivot, equalPivot, greaterThanPivot to store the partitions, sortedList to store the output sorted array. These lists are put on top of my class to reuse instead of instantiate them in every pass.

public List<T> lessThanPivot, equalPivot, greaterThanPivot, sortedList; 

The QuickSort function:

    public void quickSort(List<T> data, int start, int end)     {         if (start > end) return;         end = Math.min(data.size(), end);         T pivot = null;         //Construct buffer lists         ListIterator<T> iterator = data.listIterator(end);         while (iterator.hasPrevious() && iterator.previousIndex() >= start)         {             T current = iterator.previous();             if (pivot == null) pivot = current;             if (current.compareTo(pivot) < 0) lessThanPivot.add(current);             else if (current.compareTo(pivot) == 0) equalPivot.add(current);             else greaterThanPivot.add(current);             iterator.remove();         }         int lessThanPivotStartIndex = start + greaterThanPivot.size() + equalPivot.size();         int greaterThanPivotEndIndex = start + greaterThanPivot.size() - 1;         copyBufferListsToOriginalList(data);         //Recursively sort the less than pivot         if (lessThanPivotStartIndex < end && end <= data.size()) quickSort(data, lessThanPivotStartIndex, end);         //In case all the lessThanPivot and equalPivot has been moved to output array, recursively call to sort the whole data         //as it now contains only greaterThanPivot         else if (lessThanPivotStartIndex > data.size()) {quickSort(data, 0, data.size()); return;}          //Recursively sort the greater than pivot         if (greaterThanPivotEndIndex > start) quickSort(data, start, greaterThanPivotEndIndex);     } 

The copyBufferListsToOriginalList function:

    private void copyBufferListsToOriginalList(List<T> data)     {         if (lessThanPivot.size() <= 1) {             copy(lessThanPivot, sortedList);             copy(equalPivot, sortedList);             if (greaterThanPivot.size() <= 1) copy(greaterThanPivot, sortedList);             else copy(greaterThanPivot, data);         }else {             copy(greaterThanPivot, data);             copy(equalPivot, data);             copy(lessThanPivot, data);         }     } 

Problems

  • Even though my QuickSort can sort correctly, but it runs quite slow compare to recursive in-place versions.
  • I got StackOverflow exception when n = 10,000.

I am not sure what is wrong and what could I improve on my program.

Thanks for your all advice and stay safe.

How is Hopwood’s Java interface attack related to least common mechanism principle?

I’m trying to understand LCM and how David Hopwood’s discovery is a noteworthy example of it. This site contains two important things. First, it identifies Hopwood’s interface attack (1996) as an example of LCM, and second, it includes a description (highlighted in the screenshot below) of the issue that seems to make things more clear than anything else I could find. The problem is I don’t understand the connection between this vulnerability and LCM.

Here is a screenshot of the referenced site:


least common mechanism from princeton.edu


Hopwood made the announcement through the SRI RISKS-LIST. The full announcement released in issue 17.83 is as follows:

Date: Sat, 2 Mar 1996 23:51:49 +0000 (GMT) From: David Hopwood <david.hopwood@lady-margaret-hall.oxford.ac.uk> Subject: Java security bug (applets can load native methods)  There is a serious security bug in the class loading code for the Java development kit and Netscape (all Java-enabled versions). If an attacker can arrange for two files (a "Loader" class, and a dynamic library) to be installed in any readable directory on the client machine, he/she can by pass all of Java's security restrictions. For example, the applet can read, write and execute files on the client, with the same permissions as the user of the browser.  The only way to avoid this bug at the moment is to disable Java. In Netscape this can be done by selecting 'Disable Java' in the 'Security preferences...'section of the 'Options' menu.    This bug affects all Java implementations based on Sun's source code. It is not related to JavaScript.  Further details will be posted when Sun and Netscape have released patches.  David Hopwood david.hopwood@lmh.ox.ac.uk ------------------------------ Date: Mon, 4 Mar 1996 18:08:58 +0000 (GMT) From: David Hopwood <david.hopwood@lady-margaret-hall.oxford.ac.uk> Subject: Java security bug (applets can load native methods)  Unfortunately my news server has been off-line for the past few days.  However, I'll try to address some of the questions that were raised onstrong-java@entmp.org and in private mail about the recently-discovered bug in Java's class loading code. The same questions have probably been asked on RISKS and/or comp.lang.java as well.  Apparently I wasn't clear enough in stating that this bug allows classfiles to be loaded from _any_ directory on the client machine, not simply those on the CLASSPATH or LD_LIBRARY_PATH. This includes, for example, /tmp,~ftp/incoming, or an attacker's home directory if he/she has an account on the same system.  The attack requires two support files on the client's system: a classfile and a dynamic library. Both files must be readable by the browser, and the dynamic library must be executable (this is always true for systems that have no file permissions). The path to the classfile from the client's root directory must be known by the attacker in advance.  Code demonstrating the bug has been written and tested on Linux and Digital Unix (OSF/1). It should be portable to all POSIX systems, and with a little work, to any system that supports Java. The demonstration is very easy to extend - hiding it within any applet would require adding only two extra lines of code. Changing the C code to execute any command would be a single-line change. For that reason, the code will not be described in detail or released publically until patches are available for both Netscape2.0 and the Java Development Kit.  David Hopwood david.hopwood@lmh.ox.ac.uk 

I have a general understanding that the LCM principal says “mechanisms used to access resources should not be shared” but I’m not able to apply it very well here. I also am not familiar with Java (and I don’t think I really have to be in this instance but it seems like it would help).

My question is, “What is the shared mechanism that is used to access resources?” (Is there another way to describe the crux of the issue?)

Interface for users that need to fill in data for thousands of items

The problem I encounter is that I have thousands of items a day (e.g. transactions of toys that have been purchased in a store). My goal is to provide the users with an interface to fill in manually 10+ data fields on this transaction (e.g. toy category, is it the main toy or something you purchase as extra, what age is it for, etc.). Then, I would categorize the data by the information the users provided me. How would you recommend doing it?

Thanks!

Interface examples for handling “page notes” and highlighted text comments?

I’m working on a collections-based interface (think Pinterest or Dropbox), and we’re implementing a feature that allows users to add Notes/Comments to various elements (folders/boards, files/pages, highlighted text, etc…).

These “notes” would be accessible either via an icon (say, a small Post-It note with the total count), or a sliding tray somewhere (there could be multiple notes for a specific item). Additionally, they’ll need to access any notes they’ve added to specific text they’ve highlighted on a page. Should this be included in the standard Notes, or be treated differently? Not sure…

I’m having a hard time finding inspiration for this, and would love to see examples of Notes being handled really, really well.

Does anyone have any screenshots they could share of existing apps? Or any thoughts on how we should be handling this? I’m a bit stuck here and could use some inspiration 🙂

Thank you so much!

-Lynn

Add an element to an interface without increasing the complexity of the layout

I need to implement a text and a switch to a login interface. This is what I made:

enter image description here

The problem is that I think it is a bit inappropriate, considering the layout and colors chosen in the interface. How would you improve it? Can it be a solution to close it inside a rectangular shape and move it to the center of screen?