Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixed various errors in the C code

...

Code Block
bgColor#ccccff
#include <resource<sys/resource.h>
/* ... */
struct rlimit limit;

limit.rlim_cur = 0;
limit.rlim_max = 0;
if(!setrlimit(RLIMIT_CORE, &limit) != 0) {
    /* Handle Error */
}

/* Create or otherwise obtain some sensitive data */
fgets(secret, sizeof(secret), stdin);

...

Code Block
bgColor#CCCCFF
#include <resource<sys/resource.h>
/* ... */
struct rlimit limit;

limit.rlim_cur = 0;
limit.rlim_max = 0;
if(!setrlimit(RLIMIT_CORE, &limit) != 0) {
    /* Handle Error */
}

if(mlock(secret, sizeof(secret)) != 0) {
    /* Handle error */
}

/* Create or otherwise obtain some sensitive data */
fgets(secret, sizeof(secret), stdin);

Compliant Solution (privileged process on Windows)

Code Block
bgColor#CCCCFF

#include <resource.h>
/* ... */
struct rlimit limit;

limit.rlim_cur = 0;
limit.rlim_max = 0;
if(!setrlimit(RLIMIT_CORE, &limit)) {
    /* Handle Error */
}

if(VirtualLock(secret, sizeof(secret)) != 0) {
    /* Handle error */
}

/* Create or otherwise obtain some sensitive data */
fgets(secret, sizeof(secret), stdin);

...