My First C Program 06-30-2015, 11:28 AM
#1
Code:
#include <stdio.h>
#include <stdlib.h>
void usage() {
printf("Usage: ./postcalc.c current_post_count time posts_per_day\n");
}
int main(int argc, char *argv[]) {
if(argc > 4) {
printf("Too many arguments.\n");
usage();
}
else if(argc < 4) {
printf("You have not passed enough arguments.\n");
usage();
}
else if(argc == 4) {
int current_post_count = atoi(argv[1]);
int time = atoi(argv[2]);
int posts_per_day = atoi(argv[3]);
int result = posts_per_day * 30.436 * 12 * time;
result = result + current_post_count;
printf("In %d years, your post count will be %d.\n", time, result);
}
else {
usage();
}
return 0;
}Also, I wanted to ask whether or not the above program is vulnerable to a buffer overflow attack, and if so, why? (@Dyme? Since you're the pro at exploiting buffer overflows in TEXETs.
)
















![[+]](https://sinister.li/images/modern/collapse_collapsed.png)






















