Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1129814: Fix errors while parsing 0-terminated memory in read_pdu…
Browse files Browse the repository at this point in the history
…_at_va()
  • Loading branch information
BruceSunMozilla authored and rvandermeulen committed Feb 13, 2015
1 parent 29dcf99 commit 02e0064
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/bt-proto.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014 Mozilla Foundation
* Copyright (C) 2014-2015 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -119,12 +119,12 @@ read_pdu_at_va(const struct pdu* pdu, unsigned long offset,
break;
case '0': /* raw 0-terminated memory */
mem = va_arg(ap, void**);
chr = memchr(mem, '\0', pdu->len - offset);
chr = memchr(pdu->data + offset, '\0', pdu->len - offset);
if (!chr) {
ALOGE("string not terminated");
return -1;
}
len = memdiff(mem, chr) + 1; /* include \0 byte */
len = memdiff(pdu->data + offset, chr) + 1; /* include \0 byte */
errno = 0;
dst = malloc(len);
if (errno) {
Expand Down

0 comments on commit 02e0064

Please sign in to comment.