safety

What do you (or your company) use for wiping a machine?

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? ...

create std::string from char* in a safe way

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? ...

Is SQLite thread safe under this situation?

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...

Why do safety requirements like to discourage use of AI?

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...

Is this thread.abort() normal and safe?

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...

PHP safety with include

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])) { ...

Masking Audio

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 ...

RealPath safe?

<?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? ...

Thread safety across shared instances (C#)

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...

Bad handling of PHP sessions variables?

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 my code and then my PC died, how necessary is it to do a complete scan if i don't want my later source code to be contaminated?

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...

C# thread safety of global configuration settings

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 = ...

Thread safety... what's my "best" course of action?

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...

Does proper office ergonomics equate to better safety and more production?

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. ...

What is the most dangerous feature of C++?

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...

Photo safety on my website

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...

Functional programming in nuclear plants?

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...

Is the static safe in Android?

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 is the correct way to make web form input safe for a variety of contexts?

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...

Is sprintf(buffer, "%s […]", buffer, […]) safe?

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...