aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--csci5271/hw1/hw1markup.md43
-rwxr-xr-xcsci5271/hw1/hw1p2a.pl12
-rw-r--r--csci5271/hw1/hw1p2b.c28
-rw-r--r--csci5271/hw1/hw1p4.c27
-rw-r--r--papers/resume.tex4
5 files changed, 112 insertions, 2 deletions
diff --git a/csci5271/hw1/hw1markup.md b/csci5271/hw1/hw1markup.md
new file mode 100644
index 0000000..a870d15
--- /dev/null
+++ b/csci5271/hw1/hw1markup.md
@@ -0,0 +1,43 @@
+# Homework 1
+## Q1
+
+## Q2
+### A: Perl
+After adding a name to the request, add a semicolon followed by the command. The semicolon is the shell command separator which allows it to parse commands.
+#### Example Request
+```
+"?field-name=;perl+-e+'`command`'"
+```
+### B: C
+
+## Q3
+
+## Q4
+### A
+#### Mistake 1a: Potentially overloading the array
+If the function is called with `to` larger than outer bound of the array, there is a buffer overflow that happens. For example, running it by default with an array of size 10 with a `to` of size 11 on gcc 11.1 causes it to crash because of stack smashing.
+##### Mistake 1b: Underloading the array
+If the function is called with `from` smaller than 0 will cause some values of the array to be replaced with other values from memory. It did not crash, but it is not the intended behavior.
+#### Mistake 2:
+
+#### Mistake 3:
+
+### B: Same Signature
+```c
+ void reverse_range(int *a, int from, int to) {
+
+```
+### C: Different Signature
+```c
+ int* reverse_range(int arr[], int arrSize, int from, int to) {
+ if (from < 0 || to >= arrSize)
+ return NULL;
+ for (int i = from; i < to; i++) {
+ int temp = arr[i];
+ arr[i] = arr[to];
+ arr[to] = temp;
+ to--;
+ }
+ return arr;
+```
+## Q5 \ No newline at end of file
diff --git a/csci5271/hw1/hw1p2a.pl b/csci5271/hw1/hw1p2a.pl
new file mode 100755
index 0000000..a8bfe2e
--- /dev/null
+++ b/csci5271/hw1/hw1p2a.pl
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+print "Content-Type: text/html\r\n\r\n";
+print "<HTML><BODY>\n";
+($field_name, $username_to_look_for) = split(/=/, <>);
+chomp $username_to_look_for;
+$result = `last -1000 | grep $username_to_look_for`;
+if ($result) {
+print "$username_to_look_for has logged in recently.\n";
+} else {
+print "$username_to_look_for has NOT logged in recently.\n";
+}
+print "</BODY></HTML>\n"; \ No newline at end of file
diff --git a/csci5271/hw1/hw1p2b.c b/csci5271/hw1/hw1p2b.c
new file mode 100644
index 0000000..df5ac73
--- /dev/null
+++ b/csci5271/hw1/hw1p2b.c
@@ -0,0 +1,28 @@
+#include <fcntl.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <unistd.h>
+void silly_function(char *pathname) {
+ struct stat f, we;
+ int rfd, wfd;
+ char *buf;
+ stat(pathname, &f);
+ stat("./critical", &we);
+ if (f.st_dev == we.st_dev && f.st_ino == we.st_ino) {
+ return;
+ }
+ rfd = open(pathname, O_RDONLY);
+ buf = malloc(f.st_size - 1);
+ read(rfd, buf, f.st_size - 1);
+ close(rfd);
+ stat(pathname, &f);
+ if (f.st_dev == we.st_dev && f.st_ino == we.st_ino) {
+ return;
+ }
+ wfd = open(pathname, O_WRONLY | O_TRUNC);
+ write(wfd, buf, f.st_size - 1);
+ close(wfd);
+ free(buf);
+}
+
+int main() { silly_function("./not"); } \ No newline at end of file
diff --git a/csci5271/hw1/hw1p4.c b/csci5271/hw1/hw1p4.c
new file mode 100644
index 0000000..e449de5
--- /dev/null
+++ b/csci5271/hw1/hw1p4.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+/* Reverse the elements from FROM to TO, inclusive */
+void reverse_range(int *a, int from, int to) {
+ unsigned int *p = &a[from];
+ unsigned int *q = &a[to];
+ /* Until the pointers move past each other: */
+ while (!(p == q + 1 || p == q + 2)) {
+ /* Swap *p with *q, without using a temporary variable */
+ *p += *q; /* *p == P + Q */
+ *q = *p - *q; /* *q == P + Q - Q = P */
+ *p = *p - *q; /* *p == P + Q - P = Q */
+ /* Advance pointers towards each other */
+ p++;
+ q--;
+ }
+}
+int main() {
+ int a[10] = {255, 0, -65536, 2147483647, -2147483648,
+ -1, 0, 1, 2, 3};
+ reverse_range(a, 0, 9);
+ for (int i = 0; i < 10; i++) {
+ printf("%d ", a[i]);
+ }
+ printf("\n");
+ return 0;
+} \ No newline at end of file
diff --git a/papers/resume.tex b/papers/resume.tex
index 992d841..6137473 100644
--- a/papers/resume.tex
+++ b/papers/resume.tex
@@ -104,7 +104,7 @@
\begin{center}
\textbf{\Huge Matthew Strapp} \\ \vspace{1pt}
\small (507)429-1743 $|$ \href{mailto:matt@mattstrapp.net}{\underline{matt@mattstrapp.net}} $|$
- \href{https://git.mattstrapp.net}{\underline{git.mattstrapp.net}}
+ \href{https://git.mattstrapp.net/RossTheRoss}{\underline{cutt.ly/MSGit}}
\end{center}
@@ -126,7 +126,7 @@
{\textbf{Student Senator} $|$ University of Minnesota Senate}{April 2020 -- Present}
\resumeItemListStart
\resumeItem{Elected as one of 4 undergradutes to represent the College of Science and Engineering in the University Senate}
- \resumeItem{Organized back end of campaign that allowed students to take classes Pass/Fail in the Fall of 2020}
+ \resumeItem{Organized back end of campaign that allowed students to take classes Pass/Fail}
\resumeItem{Hosted the Academic Affairs Committee meetings over Zoom}
\resumeItemListEnd
\resumeSubHeadingListEnd