Conversation
Work in progress ...)
Now compile on debian
src/launch_server.c
Outdated
| continue ; | ||
| } | ||
| inet_ntop(rem_addr.ss_family, get_in_addr((struct sockaddr *)&rem_addr), | ||
| str, sizeof str); |
There was a problem hiding this comment.
Evidemment, my bad.
| hints.ai_socktype = SOCK_STREAM; /* Use TCP stream socket */ | ||
|
|
||
| /* Get port number as a string */ | ||
| snprintf(port_str, 6, "%d", flags_get_port()); |
There was a problem hiding this comment.
Question: snprintf met un \0 à la fin de la string ?
There was a problem hiding this comment.
Man snprintf sous debian : The functions snprintf() and vsnprintf() write at most size bytes (including the terminating null byte ('\0')) to str.
Sous OSX : The snprintf() and vsnprintf() functions will write at most size-1 of the characters printed into the output string (the size'th character then gets the terminating \0'); if the return value is greater than or equal to the size argument, the string was too short and some of the printed characters were discarded. The output is always null-terminated, unless size is 0.`
src/launch_server.c
Outdated
| int sockfd = 0, /* Read on this one */ | ||
| rem_fd = 0, /* Fd that will be attributed to the client */ | ||
| rval; /* To stock getaddrinfo() return */ | ||
| s8_t enable = 1; /* Int to enable the option in setsockopt */ |
There was a problem hiding this comment.
Fondamentalement, pour rien, ca doit etre zero ou non-zero, tu préfère unsigned ?
There was a problem hiding this comment.
Booléen du coup, pour la clareté !
src/launch_server.c
Outdated
| #define BACKLOG 10 /* How many pending connection we will keep in queue */ | ||
|
|
||
| // get sockaddr, IPv4 or IPv6: | ||
| void *get_in_addr(struct sockaddr *sa) |
There was a problem hiding this comment.
Vérifie que le pointeur qu'on t'envoie est pas NULL avant de déréférencer. Et si la fonction est utilisée nulle part ailleurs, met la static
src/launch_server.c
Outdated
|
|
||
| char str[INET6_ADDRSTRLEN]; | ||
|
|
||
| memset(&hints, 0, sizeof hints); |
There was a problem hiding this comment.
Je sais pas ce qui m'as pris sur les sizeof.
src/launch_server.c
Outdated
| sizeof(int)) == 1) | ||
| { | ||
| /* If it fails, display the error and exit */ | ||
| m_panic("Server: socket %s" , strerror(errno)); |
There was a problem hiding this comment.
Manque un freeaddrinfo ça leak
There was a problem hiding this comment.
Oublié effectivement, je patch.
- Forgot parenthesis after sizeof - Forgot a freeaddrinfo - Changed s8_t to u8_t - Checked for NULL parameters in get_in_addr - Made get_in_addr a static function
src/args.c
Outdated
|
|
||
| /** | ||
| * Path of the specifiedd PID file, if defined | ||
| * Path of the specifiedd PID file, if defined. |
|
Ok pour le code, j'attend le fix du build + coverage pour merge |
Codecov Report
@@ Coverage Diff @@
## master #3 +/- ##
=====================================
- Coverage 100% 0% -100%
=====================================
Files 1 1
Lines 41 35 -6
=====================================
- Hits 41 0 -41
- Misses 0 35 +35
Continue to review full report at Codecov.
|
Server is listening and doing nothing.