1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +03:00

connect: Use a better IP regex.

This commit is contained in:
Andreas Schneider
2010-12-28 00:24:47 +01:00
parent 4fa2e4dde1
commit 438083542d

View File

@@ -122,6 +122,8 @@ void ssh_sock_set_blocking(socket_t sock) {
#endif /* _WIN32 */ #endif /* _WIN32 */
#ifdef HAVE_REGCOMP #ifdef HAVE_REGCOMP
#define IPEXPR "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}"
static regex_t *ip_regex = NULL; static regex_t *ip_regex = NULL;
/** @internal /** @internal
@@ -134,7 +136,7 @@ int ssh_regex_init(){
int err; int err;
regex_t *regex=malloc(sizeof (regex_t)); regex_t *regex=malloc(sizeof (regex_t));
ZERO_STRUCTP(regex); ZERO_STRUCTP(regex);
err=regcomp(regex,"^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$",REG_EXTENDED | REG_NOSUB); err = regcomp(regex, IPEXPR, REG_EXTENDED | REG_NOSUB);
if(err != 0){ if(err != 0){
char buffer[128]; char buffer[128];
regerror(err,regex,buffer,sizeof(buffer)); regerror(err,regex,buffer,sizeof(buffer));