Skip to content

Commit

Permalink
Critical bug: realloc size uncorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
julienblitte committed Jul 29, 2017
1 parent 36b0222 commit 6db8d63
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ Supports **SSDP** (*UPnP* network detection part) only over **IPv4**.
Programmed mainly in **C** for *SSDP* part, with some piece in **PHP** for *UPnP* service description.

## Releases
* Version 0.23: https://github.com/julienblitte/tiny-ssdp/releases/tag/0.23
* Version 0.231: https://github.com/julienblitte/tiny-ssdp/releases/tag/0.231
2 changes: 1 addition & 1 deletion arch-armhf/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: tiny-ssdp
Version: 0.23
Version: 0.231
Architecture: armhf
Maintainer: Julien Blitte <julien.blitte@gmail.com>
Installed-Size: 1024
Expand Down
6 changes: 6 additions & 0 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ const char *http_search_variable(text t, const char *variable)
char *pattern;
size_t len;

fprintf(stderr, "<debug> http_search_variable(\"%p\",\"%s\")\n", t, variable);

len = strlen(variable)+1;
pattern = (char *)malloc(len+1); // pattern must be freed (1)

snprintf(pattern, len+1, "%s:", variable);
fprintf(stderr, "<debug> pattern: \"%s\"\n", pattern);

for(l=0; t[l]; l++)
{
fprintf(stderr, "<debug> l=%d\n", l);
fprintf(stderr, "<debug> t[l]=%p\n", t[l]);
fprintf(stderr, "<debug> strncasecmp(\"%s\",\"%s\")\n", t[l], pattern);
if (!strncasecmp(t[l], pattern, len))
{
free(pattern); // pattern freed here (1) 1/2
Expand Down
2 changes: 1 addition & 1 deletion src/textutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ text data2text(char *data)

if (i < MAX_LINES-1)
{
result = realloc(result, i+1);
result = realloc(result, sizeof(char*)*(i+1));
}

return result;
Expand Down

0 comments on commit 6db8d63

Please sign in to comment.