Docsity

CMSC 433 Homework 4: Testing BoundedAtomicQueue and Security Best Practices - Prof. Willia, Assignments of Programming Languages

Partial preview of the text

Download CMSC 433 Homework 4: Testing BoundedAtomicQueue and Security Best Practices - Prof. Willia and more Assignments Programming Languages in PDF only on Docsity!

  • CMSC

Homework 4

  • write test cases for BoundedAtomicQueue, using MultithreadedTC
  • Should be atomic, fair, and the correct size
  • You are given a correct implementation, and 4 broken implementations
  • Write test cases that distinguish them
  • Everything open, no release tests
    • this is a homework, not a project
  • Due Friday Nov 16th

Upcoming stuff

  • WebGoat security homework
  • Distributed programming
    • Map/Reduce and Hadoop

Timing notes

  • Turns out, OSX is way better than most other operating systems by default
  • On OSX (as least on Leopard), Java Thread.sleep resolution is 1 millisecond
  • On many other platforms, it is 10 milliseconds or 16 milliseconds
  • Had to adjust tests cases to fit
  • Project 4

Software Security

  • Making sure that if your software is misused, it doesn’t do any of the vast number of things you didn’t intend for the software to do

On trusting trust

  • You can hide a trojan horse in a compiler - or in the operating system

Slightly cool, but not very

interesting

  • Get spotted in a code audit

Compiler

Code generateCode(AST method) { if (method.getName() .equals(“authenticateLogin”)) { return .. code with trap door.. } if (method.getName() .equals(“generateCode”)) { return ... code with special code gen ...; } .. generate code normally }

Software defects

  • Traditional approach to correctness
    • define precondition
    • show that if precondition satisfied, output satisfied postcondition
  • Didn’t examine what happened if input didn’t satisfy precondition

#1 source of security defects

  • Untrusted, unverified and unexpected input leading to a program doing something completely unexpected - unexpected by developer - intended by attacker
  • of all the untrusted input problems, # 1 is buffer overruns in C/C++.

Stack layout

int main(int argc, char *argv[]) { int value; char buf1[80]; … } argv argc return address frame pointer buf value

gets() is evil

  • Impossible to use gets() correctly char buf[20]; gets(buf);

C String functions

char buf[20]; char * prefix = “http://”; strcpy(buf,prefix); strncat(buf, path, sizeof(buf) - strlen(buf));

sprintf

  • char buf[80]; sprintf(buf, “%s - %d\n”, path, errno);