Add PVS and fix leaks (with the help of valgrind)
Co-authored-by: Ezequiel Bellver <ebellver@itba.edu.ar> Co-authored-by: Juan Barmasch <jbarmasch@itba.edu.ar>
This commit is contained in:
parent
61236e7e58
commit
f91992bb62
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CCFLAGS = -Wall -std=c99 -pedantic
|
CCFLAGS = -Wall -std=c99 -pedantic -g
|
||||||
|
|
||||||
CLIENT=client
|
CLIENT=client
|
||||||
SERVER=server
|
SERVER=server
|
||||||
|
|
|
@ -10,7 +10,12 @@ BCSSocket (Bottler Client-Server Socket) es un sistema que...
|
||||||
|
|
||||||
## Requisitos <a name="requisitos"></a>
|
## Requisitos <a name="requisitos"></a>
|
||||||
|
|
||||||
...
|
Debe instalar gcc y make. Estos se encuentran disponibles en el repositorio de la vasta mayoría de distribuciones de Linux/macOS.
|
||||||
|
|
||||||
|
Debian/Ubuntu: `apt install gcc make`\
|
||||||
|
macOS (con [homebrew](https://brew.sh/)): `brew install gcc make`
|
||||||
|
|
||||||
|
Si tiene otra distribución consulte cómo hacerlo.
|
||||||
|
|
||||||
## Compilación <a name="compilación"></a>
|
## Compilación <a name="compilación"></a>
|
||||||
|
|
||||||
|
|
16
challenges.c
16
challenges.c
|
@ -1,5 +1,9 @@
|
||||||
|
// This is a personal academic project. Dear PVS-Studio, please check it.
|
||||||
|
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||||
#include "include/challenges.h"
|
#include "include/challenges.h"
|
||||||
|
|
||||||
|
char too_easy = 'a';
|
||||||
|
|
||||||
char genChallenge(FILE * stream, char ** output, challenge_t challenge) {
|
char genChallenge(FILE * stream, char ** output, challenge_t challenge) {
|
||||||
printf("------------- DESAFIO -------------\n");
|
printf("------------- DESAFIO -------------\n");
|
||||||
printf("%s\n\n", challenge.message);
|
printf("%s\n\n", challenge.message);
|
||||||
|
@ -11,12 +15,12 @@ char genChallenge(FILE * stream, char ** output, challenge_t challenge) {
|
||||||
printf("%s\n\n", challenge.question);
|
printf("%s\n\n", challenge.question);
|
||||||
|
|
||||||
size_t linecap = 0;
|
size_t linecap = 0;
|
||||||
ssize_t linelen;
|
if (getline(output, &linecap, stream) < 0)
|
||||||
|
|
||||||
if ((linelen = getline(output, &linecap, stream)) < 0)
|
|
||||||
printSystemError("Challenges: getline()");
|
printSystemError("Challenges: getline()");
|
||||||
|
|
||||||
return !strcmp(*output, challenge.flag);
|
int ans = strcmp(*output, challenge.flag);
|
||||||
|
// free(*output);
|
||||||
|
return !ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeChallenge() {
|
void writeChallenge() {
|
||||||
|
@ -68,6 +72,9 @@ void quineChallenge() {
|
||||||
printf("La respuesta es chin_chu_lan_cha\n");
|
printf("La respuesta es chin_chu_lan_cha\n");
|
||||||
else
|
else
|
||||||
printf("\ndiff encontró diferencias.\n");
|
printf("\ndiff encontró diferencias.\n");
|
||||||
|
|
||||||
|
if (system("rm quine") < 0)
|
||||||
|
printSystemError("Challenges: system()");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("\nENTER para reintentar.\n");
|
printf("\nENTER para reintentar.\n");
|
||||||
|
@ -76,7 +83,6 @@ void quineChallenge() {
|
||||||
void gdbme(char * output) {
|
void gdbme(char * output) {
|
||||||
if (getpid() == 0x12345678) {
|
if (getpid() == 0x12345678) {
|
||||||
*output = 1;
|
*output = 1;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else *output = 0;
|
else *output = 0;
|
||||||
}
|
}
|
||||||
|
|
2
client.c
2
client.c
|
@ -1,3 +1,5 @@
|
||||||
|
// This is a personal academic project. Dear PVS-Studio, please check it.
|
||||||
|
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||||
#include "include/client.h"
|
#include "include/client.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
2
errors.c
2
errors.c
|
@ -1,3 +1,5 @@
|
||||||
|
// This is a personal academic project. Dear PVS-Studio, please check it.
|
||||||
|
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||||
#include "include/errors.h"
|
#include "include/errors.h"
|
||||||
|
|
||||||
void printError(char * string) {
|
void printError(char * string) {
|
||||||
|
|
|
@ -27,6 +27,4 @@ void questionChallenge();
|
||||||
void quineChallenge();
|
void quineChallenge();
|
||||||
void gdbChallenge();
|
void gdbChallenge();
|
||||||
|
|
||||||
char too_easy = 'a';
|
|
||||||
|
|
||||||
#endif
|
#endif
|
2
quine.c
2
quine.c
|
@ -1 +1,3 @@
|
||||||
|
// This is a personal academic project. Dear PVS-Studio, please check it.
|
||||||
|
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||||
main() { char *s="main() { char *s=%c%s%c; printf(s,34,s,34,10); }%c"; printf(s,34,s,34,10); }
|
main() { char *s="main() { char *s=%c%s%c; printf(s,34,s,34,10); }%c"; printf(s,34,s,34,10); }
|
||||||
|
|
7
server.c
7
server.c
|
@ -1,3 +1,5 @@
|
||||||
|
// This is a personal academic project. Dear PVS-Studio, please check it.
|
||||||
|
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||||
#include "include/server.h"
|
#include "include/server.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
@ -52,11 +54,10 @@ void startChallenge(int fd) {
|
||||||
printf("Respuesta incorrecta: %s\n", output);
|
printf("Respuesta incorrecta: %s\n", output);
|
||||||
sleep(TIME_SLEEP);
|
sleep(TIME_SLEEP);
|
||||||
}
|
}
|
||||||
|
free(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fclose(stream);
|
fclose(stream);
|
||||||
free(output);
|
|
||||||
free(stream);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
Loading…
Reference in New Issue