Skip to content

Commit

Permalink
X3F parser possible buffer overrun
Browse files Browse the repository at this point in the history
  • Loading branch information
alextutubalin committed Apr 27, 2018
1 parent cb4ced2 commit 6f89e55
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/libraw_cxx.cpp
Expand Up @@ -6098,18 +6098,19 @@ const char *LibRaw::strprogress(enum LibRaw_progress p)

void x3f_clear(void *p) { x3f_delete((x3f_t *)p); }

static char *utf2char(utf16_t *str, char *buffer)
void utf2char(utf16_t *str, char *buffer, unsigned bufsz)
{
if(bufsz<1) return;
buffer[bufsz-1] = 0;
char *b = buffer;

while (*str != 0x00)
while (*str != 0x00 && --bufsz>0)
{
char *chr = (char *)str;
*b++ = *chr;
str++;
}
*b = 0;
return buffer;
}

static void *lr_memmem(const void *l, size_t l_len, const void *s, size_t s_len)
Expand Down Expand Up @@ -6173,8 +6174,8 @@ void LibRaw::parse_x3f()
for (i = 0; i < PL->num_properties; i++)
{
char name[100], value[100];
utf2char(P[i].name, name);
utf2char(P[i].value, value);
utf2char(P[i].name, name,sizeof(name));
utf2char(P[i].value, value,sizeof(value));
if (!strcmp(name, "ISO"))
imgdata.other.iso_speed = atoi(value);
if (!strcmp(name, "CAMMANUF"))
Expand Down

0 comments on commit 6f89e55

Please sign in to comment.