Question

Examine the line management routines in this dir. It handles any number of lines (or queues),...

Examine the line management routines in this dir. It handles any number
of lines (or queues), and returns a pointer to the line that is created.
The header file (queueHeader.h), the line manager (queueManager.c) and a
'skeleton' driver program, lineMain.c, are given.

item 2 [add, as comment, at top of lineMain.c, mark the comment as ITEM 2 - 4 Vulnerabilities]:

Analyze the given code given and explain clearly any four vulnerabilities, each
description of about 5 or 6 sentences. Each vulnerability has to be a
very specific problem, not something general like buffer overflow etc.

Item 3 lineExploit.c:
For any ONE vulnerability, write an exploit, mainExploit.c;
exploit code should be readable and well-documented, else you get 0.
lineExploit.c should have comments at top that describes the vulnerability you are exploiting and how your exploit
exposes the vulnerability. Note that just crashing the program is NOT an exploit.
Note that you do NOT modify the files: queueHeader.h, queueManager.c

Item 4 [add, as comment, at top of lineMain.c, mark the comment as ITEM 4 - ONE Vulnerability possible fix]:
For any ONE of the remaining vulnerabilities, state the vulnerability, and describe how you would fix it; however, NO need
to provide the code for actual fix

---------------

//lineMain.c   

/**

This is just a skeleton. Has NO meat. Instead, it just shows
how to run in DeterLab

$ pwd
/proj/Security3210/3210/Homework5LineManager
$ ls
lineMain.c queueHeader.h queueManager.c
$ cc lineMain.c
$ ./a.out
Welcome to Homework 5. Just a skeleton, Has NO meat.

*/


#include
#include
#include
#include
#include "queueManager.c"

int main(int argc, const char * argv[]) {

printf("Welcome to Homework 5. Just a skeleton, Has NO meat.\n\n");
return 0;
}
-------------
//queueHeader.h

/*
* line Manager Header file
*/


/*
* the queue structure
*/
typedef struct queue {
   int *que;       /* the actual array of queue elements */
   int head;       /* head index in que of the queue */
   int count;       /* number of elements in queue */
   int size;       /* max number of elements in queue */
} QUEUE;

/*
* the library functions
*/
void queueManage(QUEUE **, int, int);   /* create or delete a queue */
void addToQueue(QUEUE *, int);   /* add to queue */
void removeFromQueue(QUEUE *, int *);   /* remove from queue */


---------------
//queueManager.c


/*
* line Manager
*/
#include
#include
#include "queueHeader.h"

/*
* create or delete a queue
*
* PARAMETERS:   QUEUE **qptr   space for, or pointer to, queue
*        int flag   1 for create, 0 for delete
*       int size   max elements in queue
*/
void queueManage(QUEUE **qptr, int flag, int size)
{
   if (flag){
       /* allocate a new queue */
       *qptr = malloc(sizeof(QUEUE));
       (*qptr)->head = (*qptr)->count = 0;
       (*qptr)->que = malloc(size * sizeof(int));
       (*qptr)->size = size;
   }
   else{
       /* delete the current queue */
       (void) free((*qptr)->que);
       (void) free(*qptr);
   }
}

/*
* add an element to an existing queue
*
* PARAMETERS:   QUEUE *qptr   pointer for queue involved
*       int n       element to be appended
*/
void addToQueue(QUEUE *qptr, int n)
{
   /* add new element to tail of queue */
   qptr->que[(qptr->head + qptr->count) % qptr->size] = n;
   qptr->count++;

}

/*
* take an element off the front of an existing queue
*
* PARAMETERS:   QUEUE *qptr   pointer for queue involved
*       int *n       storage for the return element
*/
void removeFromQueue(QUEUE *qptr, int *n)
{
   /* return the element at the head of the queue */
   *n = qptr->que[qptr->head++];
   qptr->count--;
   qptr->head %= qptr->size;
}

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Examine the line management routines in this dir. It handles any number of lines (or queues),...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT