minisoap.c: make soapPostSubmit() return -1 for errors

This commit is contained in:
Thomas Bernard 2015-10-26 11:27:10 +01:00
parent fb02299fff
commit bbbbb0c95a
1 changed files with 4 additions and 4 deletions

View File

@ -1,7 +1,7 @@
/* $Id: minisoap.c,v 1.23 2014/11/04 22:31:55 nanard Exp $ */ /* $Id: minisoap.c,v 1.23 2014/11/04 22:31:55 nanard Exp $ */
/* Project : miniupnp /* Project : miniupnp
* Author : Thomas Bernard * Author : Thomas Bernard
* Copyright (c) 2005-2014 Thomas Bernard * Copyright (c) 2005-2015 Thomas Bernard
* This software is subject to the conditions detailed in the * This software is subject to the conditions detailed in the
* LICENCE file provided in this distribution. * LICENCE file provided in this distribution.
* *
@ -43,10 +43,10 @@ httpWrite(int fd, const char * body, int bodysize,
/* Note : my old linksys router only took into account /* Note : my old linksys router only took into account
* soap request that are sent into only one packet */ * soap request that are sent into only one packet */
char * p; char * p;
/* TODO: AVOID MALLOC */ /* TODO: AVOID MALLOC, we could use writev() for that */
p = malloc(headerssize+bodysize); p = malloc(headerssize+bodysize);
if(!p) if(!p)
return 0; return -1;
memcpy(p, headers, headerssize); memcpy(p, headers, headerssize);
memcpy(p+headerssize, body, bodysize); memcpy(p+headerssize, body, bodysize);
/*n = write(fd, p, headerssize+bodysize);*/ /*n = write(fd, p, headerssize+bodysize);*/
@ -106,7 +106,7 @@ int soapPostSubmit(int fd,
"\r\n", "\r\n",
url, httpversion, host, portstr, bodysize, action); url, httpversion, host, portstr, bodysize, action);
if ((unsigned int)headerssize >= sizeof(headerbuf)) if ((unsigned int)headerssize >= sizeof(headerbuf))
return 0; return -1;
#ifdef DEBUG #ifdef DEBUG
/*printf("SOAP request : headersize=%d bodysize=%d\n", /*printf("SOAP request : headersize=%d bodysize=%d\n",
headerssize, bodysize); headerssize, bodysize);