[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Minor feature additions


On Sun, 2009-07-12 at 23:08 +0200, Aris Adamantiadis wrote:

> I have implemented the change as we discussed, by a regular expression 
> matching in the connect code. look commit 
> 052073c36d33089d3a99992840c88c6245461813.

Why not use the "standard" regexp for IPV4 addresses?

</nk>

diff --git a/libssh/connect.c b/libssh/connect.c
index 91ec029..c82488b 100644
--- a/libssh/connect.c
+++ b/libssh/connect.c
@@ -108,7 +108,7 @@ int ssh_regex_init(){
     int err;
     regex_t *regex=malloc(sizeof (regex_t));
     ZERO_STRUCTP(regex);
-    err=regcomp(regex,"^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$",REG_EXTENDED | REG_NOSUB);
+    err=regcomp(regex,"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$",REG_EXTENDED | REG_NOSUB);
     if(err != 0){
       char buffer[128];
       regerror(err,regex,buffer,sizeof(buffer));

References:
Minor feature additionsChris Backas <chb@xxxxxxxxxxxxxxxxxx>
Re: Minor feature additionsAndreas Schneider <mail@xxxxxxxxxxxx>
Re: Minor feature additionsAris Adamantiadis <aris@xxxxxxxxxxxx>
Re: Minor feature additionsChris Backas <chb@xxxxxxxxxxxxxxxxxx>
Re: Minor feature additionsAris Adamantiadis <aris@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org