bilibili / ijkplayer

Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.
GNU General Public License v2.0
32.56k stars 8.13k forks source link

fix(ijkplayer): fix address overflow #5524

Open th1nk3r-ing opened 1 year ago

th1nk3r-ing commented 1 year ago

It would cause overflow when the highest bit of the address is 1. So, we should using strtoull, not strtoll

th1nk3r-ing commented 1 year ago

The test code is :

int main(void)
{
    const char *pStr = "0xb400007896140dc0";
    uint64_t out = strtoull(pStr, NULL, 0);
    uint64_t out1 = strtoll(pStr, NULL, 0);

    printf("[%s %d] pStr:[%s], strtoll:[0x%"PRIx64"], strtoull:[0x%"PRIx64"]",
        __func__, __LINE__, pStr, out1, out);
    return 0;
}

result : [main 13] pStr:[0xb400007896140dc0], strtoll:[0x7fffffffffffffff], strtoull:[0xb400007896140dc0]