]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/internal/io/HostAddress_p.cpp
Added FTP support (text-tested, not BAM)
[bamtools.git] / src / api / internal / io / HostAddress_p.cpp
index aa3c9a3cece29e2165d83930b583c40c14d0e548..9d4fc97cfd357ceab1c2f96749259c911254dae9 100644 (file)
@@ -15,12 +15,6 @@ using namespace std;
 namespace BamTools {
 namespace Internal {
 
-// convenience 'isalpha' wrapper
-static inline
-bool isAlpha(char c) {
-    return ( isalpha(c) != 0 );
-}
-
 // split a string into fields, on delimiter character
 static inline
 vector<string> split(const string& source, char delim) {
@@ -57,6 +51,13 @@ bool parseIp4(const string& address, uint32_t& maybeIp4 ) {
     uint32_t ipv4(0);
     for ( uint8_t i = 0; i < 4; ++i ) {
 
+        const string& field = addressFields.at(i);
+        const size_t fieldSize = field.size();
+        for ( size_t j = 0; j < fieldSize; ++j ) {
+            if ( !isdigit(field[j]) )
+                return false;
+        }
+
         int value = atoi( addressFields.at(i).c_str() );
         if ( value < 0 || value > 255 )
             return false;