diff options
author | Haru <haru@dotalux.com> | 2015-05-17 02:35:40 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2015-05-17 02:35:53 +0200 |
commit | b9a8ad743a78d5053482cb4d47d2795252ec9095 (patch) | |
tree | 40d10510054cd3dd254c366ccbe550817cb3e4ec /src/char/geoip.c | |
parent | b2b597c523f19fbacaf052117d47f254483c6e0e (diff) | |
download | hercules-b9a8ad743a78d5053482cb4d47d2795252ec9095.tar.gz hercules-b9a8ad743a78d5053482cb4d47d2795252ec9095.tar.bz2 hercules-b9a8ad743a78d5053482cb4d47d2795252ec9095.tar.xz hercules-b9a8ad743a78d5053482cb4d47d2795252ec9095.zip |
Fixed some issues detected by coverity scan
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/char/geoip.c')
-rw-r--r-- | src/char/geoip.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/char/geoip.c b/src/char/geoip.c index 889958e16..5d3324ab2 100644 --- a/src/char/geoip.c +++ b/src/char/geoip.c @@ -145,18 +145,20 @@ void geoip_init(void) } // Search database type - fseek(db, -3l, SEEK_END); - for (i = 0; i < GEOIP_STRUCTURE_INFO_MAX_SIZE; i++) { - if (fread(delim, sizeof(delim[0]), 3, db) != 3) { - db_type = 0; - break; - } - if (delim[0] == 255 && delim[1] == 255 && delim[2] == 255) { - if (fread(&db_type, sizeof(db_type), 1, db) != 1) { + if (fseek(db, -3l, SEEK_END) != 0) { + db_type = 0; + } else { + for (i = 0; i < GEOIP_STRUCTURE_INFO_MAX_SIZE; i++) { + if (fread(delim, sizeof(delim[0]), 3, db) != 3) { db_type = 0; + break; + } + if (delim[0] == 255 && delim[1] == 255 && delim[2] == 255) { + if (fread(&db_type, sizeof(db_type), 1, db) != 1) { + db_type = 0; + } + break; } - break; - } else { if (fseek(db, -4l, SEEK_CUR) != 0) { db_type = 0; break; |