aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Plate <elupus@ecce.se>2007-07-18 07:57:26 +0000
committerBenoit Fouet <benoit.fouet@free.fr>2007-07-18 07:57:26 +0000
commit104d04182d85e8538e8934c072432a05ab7ed999 (patch)
tree5a816753608f3a40a41b512f01292fa88b2ce7b1
parentf1752010048845518d45eb35cb2ebc827b139280 (diff)
downloadffmpeg-104d04182d85e8538e8934c072432a05ab7ed999.tar.gz
fix emulated inet_aton so that it fails for invalid addresses
patch by elupus: \elupus ecce se/ original thread: [FFmpeg-devel] [PATCH] emulated inet_aton doesn't fail for invalidaddresses date: 07/15/2007 12:40 AM Originally committed as revision 9731 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavformat/os_support.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavformat/os_support.c b/libavformat/os_support.c
index e28a7bc748..5342a02ed0 100644
--- a/libavformat/os_support.c
+++ b/libavformat/os_support.c
@@ -46,16 +46,17 @@ int inet_aton (const char * str, struct in_addr * add)
add1 = atoi(pch);
pch = strpbrk(pch,".");
- if (pch == 0 || ++pch == 0) goto done;
+ if (pch == 0 || ++pch == 0) return 0;
add2 = atoi(pch);
pch = strpbrk(pch,".");
- if (pch == 0 || ++pch == 0) goto done;
+ if (pch == 0 || ++pch == 0) return 0;
add3 = atoi(pch);
pch = strpbrk(pch,".");
- if (pch == 0 || ++pch == 0) goto done;
+ if (pch == 0 || ++pch == 0) return 0;
add4 = atoi(pch);
-done:
+ if (!add1 || (add1|add2|add3|add4) > 255) return 0;
+
add->s_addr=(add4<<24)+(add3<<16)+(add2<<8)+add1;
return 1;