Homework Notes from Sean

Slides:



Advertisements
Similar presentations
Course Introduction Bryce Boe 2013/06/25 CS24, Summer 2013 C.
Advertisements

CSE 451: Operating Systems Section 3 Project 0 recap, Project 1.
CSE 451: Operating Systems Section 1. Why are you here? 9/30/102.
Stack buffer overflow
CSE 451: Operating Systems Section 1 Intro, C programming, project 0.
Buffer overflows.
Today Review of Directory of Slot Block Organizations Heap Files Program 1 Hints Ordered Files & Hash Files RAID.
Chapter 6 Buffer Overflow. Buffer Overflow occurs when the program overwrites data outside the bounds of allocated memory It was one of the first exploited.
1 Homework HW6 due class 22 K&R 6.6 K&R 5.7 – 5.9 (skipped earlier) Finishing up K&R Chapter 6.
Chapter 0.2 – Pointers and Memory. Type Specifiers  const  may be initialised but not used in any subsequent assignment  common and useful  volatile.
CSE 451 – Operating Systems Section, Autumn 2003 TAs: Mike Swift Adrienne Noble
4061 Session 15 (3/6). Today More about signals A (relevant) aside Quiz review.
Overflow Examples 01/13/2012. ACKNOWLEDGEMENTS These slides where compiled from the Malware and Software Vulnerabilities class taught by Dr Cliff Zou.
CSE 451: Operating Systems Section 1. Why are you here?  Because you want to work for Microsoft and hack on the Windows kernel? 3/29/  Because.
CSE 451: Operating Systems Section 1 Intro, C programming, project 0.
Memory Layout, File I/O Bryce Boe 2013/06/27 CS24, Summer 2013 C.
CSE 451: Operating Systems Section 3: Project 0 recap, Project 1.
Generic lists Vassilis Athitsos. Problems With Textbook Interface? Suppose that we fix the first problem, and we can have multiple stacks. Can we have.
CSE 332: C++ template examples Today: Using Class and Function Templates Two examples –Function template for printing different types –Class template for.
1 C Basics Monday, August 30, 2010 CS 241. Announcements MP1, a short machine problem, will be released today. Due: Tuesday, Sept. 7 th at 11:59pm via.
Principles of Imperative Computation Lecture 1 January 15 th, 2012.
CSE 333 – SECTION 1 C, Introduction to and Working with.
Software Security. Bugs Most software has bugs Some bugs cause security vulnerabilities Incorrect processing of security related data Incorrect processing.
CSE 451 Section 1 C Refresher (or introduction?) Project 0.
“Success consists of going from failure to failure without loss of enthusiasm.” Winston Churchill.
APS105 Malloc and 2D Arrays (text Ch6.4, Ch10.2).
Heap Overflows. What is a Heap? malloc(), free(), realloc() Stores global variables Automatic memory allocation/deallocation Allocated at runtime Implemented.
1 Binghamton University Exam 1 Review CS Binghamton University Birds eye view -- Topics Information Representation Bit-level manipulations Integer.
CSE 451 Section Topics – Introductions – Division of Labor – Office Hours – Charge – Homework 1 – Project 0 – GDB – C Refresher.
Homework 1.
Dynamic Allocation in C
YongChul Kwon CSE451 Section 1: Spring 2006 YongChul Kwon
CSE 374 Programming Concepts & Tools
Protecting Memory What is there to protect in memory?
Protecting Memory What is there to protect in memory?
CSE 451 C refresher.
CSE 374 Programming Concepts & Tools
A bit of C programming Lecture 3 Uli Raich.
Protecting Memory What is there to protect in memory?
How to do corrections!!!!.
Homework Reading Machine Projects Labs
Secure Software Development: Theory and Practice
Website operation instructions for applicants
We’ll be spending minutes talking about Quiz 1 that you’ll be taking at the next class session before you take the Gateway Quiz today.
Programmazione I a.a. 2017/2018.
CSC 253 Lecture 8.
Scholarship America Dollars for Scholars: Completing the Student Profile All Dollars for Scholars scholarships are applied for online via the Dollars.
CSC 253 Lecture 8.
Terminos españoles de ingeneria de computacion.
Assembly Language Programming I: Introduction
Accessing the Test: Logging In
Computer Systems Security
Review and Q/A.
Hash Tables: A basic O(1)verview
CSC 495/583 Topics of Software Security Format String Bug (2) & Heap
Welcome to Foundations of Math 3!
CSE451 Fall 2008 Section 1 Roxana Geambasu
Jeff West - Quiz Section 8
Indexing Lecture 15.
January 8, 2004 Adrienne Noble
WESTELL 2011 Instructions for Online Material Ordering
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2017
GCSE Computer Science System Software Workbook Year 10 Half Term 4
Homework Reading Machine Projects Labs
INFO 344 Web Tools And Development
Intermediate Pointers & Basic Structures
SPL – PS2 C++ Memory Handling.
CSE 303 Concepts and Tools for Software Development
Scholarship America Dollars for Scholars: Completing the Student Profile All Dollars for Scholars scholarships are applied for online via the Dollars.
Scholarship America Dollars for Scholars: Completing the Student Profile All Dollars for Scholars scholarships are applied for online via the Dollars.
Presentation transcript:

Homework Notes from Sean From now on, turn in HW via the online dropbox that is linked from the course website On homeworks, make sure you give support and/or specific examples when answering the questions OS is about tradeoffs and often there is not a single correct answer (there are incorrect answers) Back up your answer with evidence and strong reasoning

Looking Forward... Next Project Shells System Calls Forkbomb (don't use attu!) Read info on web page Try to log in Let us know if there are any problems VMWare will be useful

Common C Pitfalls (1)‏ What’s wrong and how to fix it? char* get_city_name(double latitude, double longitude) { char city_name[100]; … return city_name; }

Common C Pitfalls (1)‏ Problem: return pointer to statically allocated mem. Solution: allocate on heap char* get_city_name(double latitude, double longitude) { char* city_name = (char*)malloc(100); … return city_name; }

Slightly more subtle example: typedef struct _city_info_t { char* name; … … } city_info_t; city_info get_city_name(double latitude, double longitude) { city_info_ city_info; char city_name[100]; city_info.name = city_name; return city_info; }

Common C Pitfalls (2)‏ What’s wrong and how to fix it? char* buf = (char*)malloc(32); strcpy(buf, argv[1]);

Common C Pitfalls (2)‏ Problem: Buffer overflow Solution: int buf_size = 32; char* buf = (char*)malloc(buf_size); strncpy(buf, argv[1], buf_size); Are buffer overflow bugs important?

Common C Pitfalls (3)‏ What’s wrong and how to fix it? char* buf = (char*)malloc(32); strncpy(buf, “hello”, 32); printf(“%s\n”, buf); buf = (char*)malloc(64); strncpy(buf, “bye”, 64); free(buf);

Common C Pitfalls (3)‏ Problem: Memory leak Solution: char* buf = (char*)malloc(32); strncpy(buf, “hello”, 32); printf(“%s\n”, buf); free(buf); buf = (char*)malloc(64); … Are memory leaks important? OS, web server, web browser, your projects?

Bug in all previous examples We didn’t handle memory allocation failures: char *buf = (char*)malloc(32); if (buf == NULL) return; You should do that in your code This is the hint that many of you have been asking for

Project 0 Project 0 Due Friday at 11:59pm Submit using the turnin program on Linux machines Please follow instructions on projects page Seriously, follow the instructions Note: turnin accepts the last thing you submit Good comments help me deliver good grades

Project 0 Discussion Why pass a reference to a pointer? Code example Hash table discussion Hash function Collision resolution Key equality testing Edge case behavior (sane and well-documented)

Questions and Answers OS concepts Project 0 OMG WHAT IS A POINTER?