I have two computers, and I'm thinking about getting rid of one of them, but I want to make sure that it's clean of anything of mine before doing so. What have you used or does your company use for this purpose?
...
I have a char* p, which points to a 0-terminated string.
How do I create a C++ string from it in an exception-safe way?
Here is an unsafe version:
string foo()
{
char *p = get_string();
string str( p );
free( p );
return str;
}
An obvious solution would be to try-catch - any easier ways?
...
I require database access operations from several threads, through a singleton object, which holds a database connection. I read from SQLite3's website, saying that 'an sqlite3 structure could only be used in the same thread that called sqlite3_open() to create it. You could not open a database in one thread then pass the handle off to a...
Seems that requirements on safety do not seem to like systems that use AI for safety-related requirements (particularly where large potential risks of desctruction/death are involved). Can anyone suggest why? I always thought that, provided you program your logic properly, the more intelligence you put in an algorithm, the more likely th...
I created a custom autocomplete control, when the user press a key it queries the database server (using Remoting) on another thread. When the user types very fast, the program must cancel the previously executing request/thread.
I previously implemented it as AsyncCallback first, but i find it cumbersome, too many house rules to fol...
How safe would you say this is?
$pages = array("about", "help", "login");
$pagesWithId = array("shownews", "showuser", "showfile");
if (in_array($_GET['page'], $pages)) {
include('includes/'.$_GET['page'].'.php');
include('templates/'.$_GET['page'].'.html');
}
foreach ($pagesWithId as $page) {
if (ctype_digit($_GET[$page])) {
...
When music is publicly streamed on a website, most of the time they are just linking .mp3 files. Although that doesn't stop anyone from downloading it.
How would you prevent this?
I had a few ideas:
To have the music be in say directory, /tmp/name.mp3 but have it stream through /music/name.mp3.
Use a header to check and see if there ...
<?php
if (preg_match('/^[a-z0-9]+$/', $_GET['p'])) {
$page = realpath('pages/'.$_GET['p'].'.php');
$tpl = realpath('templates/'.$_GET['p'].'.html');
if ($page && $tpl) {
include $page;
include $tpl;
} else {
include('error.php');
}
}
?>
How safe would you say this is?
...
I use a factory pattern to create a custom object which is loaded from a cache if possible.
There are no static members or functions on the custom object.
Assuming 2 threads call the factory and are both returned references to the same object from the cache. (i.e. No new operator, in ref to answer below, object returned from a collectio...
I'm currently using the following code in my cms to check if visitor is logged in as admin so that he can edit the current page:
if($_SESSION['admin']=="1")
{
echo "<a href="foobar/?update">edit</a>";
}
But I'm worried that the code is unsafe. Can't $_session variables easily be modified by the user?
What would be a safer pra...
let's say I am writing a Ruby on Rails program and while editing a file, the machine blue screened. in this case, how necessary is it to re-scan the whole hard drive if I don't want my future files to be damaged?
Let's say if the OS is deleting a tmp file at the moment when my computer crashed, and still have some pointers to some sect...
In a C# app, suppose I have a single global class that contains some configuration items, like so :
public class Options
{
int myConfigInt;
string myConfigString;
..etc.
}
static Options GlobalOptions;
the members of this class will be uses across different threads :
Thread1: GlobalOptions.myConfigString = ...
I'm wondering what is the "best" way to make data thread-safe.
Specifically, I need to protect a linked-list across multiple threads -- one thread might try to read from it while another thread adds/removes data from it, or even frees the entire list. I've been reading about locks; they seem to be the most commonly used approach, but ap...
This question is directed more for the users who have experience in many different work environments.
My boss's brother works for a large oil and gas company, and I have heard stories of some weird ergonomic policies that they have in place like having adjustable cubicle desk heights, forcing breaks after a certain amount of time, etc.
...
I've heard lots of times that phrase of Bjarne Stroustrup "C++ makes it harder to shoot yourself in the foot; but when you do, it takes off the whole leg" and I don't really know if it is as terrible as it sounds.
What's the worst thing that has ever happened to you (or more properly, to your software) while programming in C++? In which...
Hi I created a website from scratch using HTML and style sheets by following a "How to...." book so I am at a very basic level of knowledge.
My question is I have photos on my site wonder how safe they are. Can I make them safe? Can anyone copy them? Would a password to access the site help?
Any help will be much appreciated.
Thanks
W...
After reading this question I just wondered whether it would be a good idea to use Haskell (or other functional programming languages) in mission critical industries.
Apart from Erlang, most languages followed imperative/design-by-contract paradigms (Ada, Eiffel, C++).
But what about the functional ones?
The resulting code would be e...
I use a single static class in my code that defines a static field which I'm reusing between Activity onStop/onStart invocations. Here's a scenario:
User clicks on "Authorize" button (static data is initialized)
Activity is stopped and web browser is called
Browser executes callback and Activity is restored (static data is reused)
At...
What do you all think is the correct (read: most flexible, loosely coupled, most robust, etc.) way to make user input from the web safe for use in various parts of a web application? Obviously we can just use the respective sanitization functions for each context (database, display on screen, save on disk, etc.), but is there some gener...
I saw use of this pattern to concatenate onto a string in some code I was working on:
sprintf(buffer, "%s <input type='file' name='%s' />\r\n", buffer, id);
sprintf(buffer, "%s</td>", buffer);
and I'm fairly certain it's not safe C. You'll notice that buffer is both the output and the first input.
Apart from the obvious possibility o...