X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Flocale%2F__mo_lookup.c;h=d18ab7744246bd286fbc8a67117c320a29169700;hb=1e4204d522670a1d8b8ab85f1cfefa960547e8af;hp=8112d91c441c08133c900a0682da4c1eb39d9d68;hpb=41421d6beb3f17aa8838f7cdaad9cd16b4c451f6;p=musl diff --git a/src/locale/__mo_lookup.c b/src/locale/__mo_lookup.c index 8112d91c..d18ab774 100644 --- a/src/locale/__mo_lookup.c +++ b/src/locale/__mo_lookup.c @@ -18,12 +18,16 @@ const char *__mo_lookup(const void *p, size_t size, const char *s) o/=4; t/=4; for (;;) { + uint32_t ol = swapc(mo[o+2*(b+n/2)], sw); uint32_t os = swapc(mo[o+2*(b+n/2)+1], sw); - if (os >= size) return 0; + if (os >= size || ol >= size-os || ((char *)p)[os+ol]) + return 0; int sign = strcmp(s, (char *)p + os); if (!sign) { + uint32_t tl = swapc(mo[t+2*(b+n/2)], sw); uint32_t ts = swapc(mo[t+2*(b+n/2)+1], sw); - if (ts >= size) return 0; + if (ts >= size || tl >= size-ts || ((char *)p)[ts+tl]) + return 0; return (char *)p + ts; } else if (n == 1) return 0;