projects
/
citadel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* lets start knit-picking on buffersizes.
[citadel.git]
/
webcit
/
webcit.c
diff --git
a/webcit/webcit.c
b/webcit/webcit.c
index 25efc69e123bb6a578fbcf2f6f79b878eb3a7070..54001abb39fc67d9516bc9393112b95e08906f04 100644
(file)
--- a/
webcit/webcit.c
+++ b/
webcit/webcit.c
@@
-204,15
+204,16
@@
void wDumpContent(int print_standard_html_footer)
* \param nbsp If nonzero, spaces are converted to non-breaking spaces.
* \param nolinebreaks if set, linebreaks are removed from the string.
*/
* \param nbsp If nonzero, spaces are converted to non-breaking spaces.
* \param nolinebreaks if set, linebreaks are removed from the string.
*/
-
void stresc(char *target
, char *strbuf, int nbsp, int nolinebreaks)
+
long stresc(char *target, long tSize
, char *strbuf, int nbsp, int nolinebreaks)
{
{
- char *aptr, *bptr;
+ char *aptr, *bptr
, *eptr
;
*target = '\0';
aptr = strbuf;
bptr = target;
*target = '\0';
aptr = strbuf;
bptr = target;
+ eptr = target + tSize - 6; // our biggest unit to put in...
- while (!IsEmptyStr(aptr) ){
+ while (
(bptr < eptr) &&
!IsEmptyStr(aptr) ){
if (*aptr == '<') {
memcpy(bptr, "<", 4);
bptr += 4;
if (*aptr == '<') {
memcpy(bptr, "<", 4);
bptr += 4;
@@
-250,10
+251,10
@@
void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks)
bptr += 6;
}
else if ((*aptr == '\n') && (nolinebreaks)) {
bptr += 6;
}
else if ((*aptr == '\n') && (nolinebreaks)) {
-
strcat(bptr, "");
/* nothing */
+
*bptr='\0';
/* nothing */
}
else if ((*aptr == '\r') && (nolinebreaks)) {
}
else if ((*aptr == '\r') && (nolinebreaks)) {
-
strcat(bptr, "");
/* nothing */
+
*bptr='\0';
/* nothing */
}
else{
*bptr = *aptr;
}
else{
*bptr = *aptr;
@@
-262,6
+263,9
@@
void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks)
aptr ++;
}
*bptr = '\0';
aptr ++;
}
*bptr = '\0';
+ if ((bptr = eptr - 1 ) && !IsEmptyStr(aptr) )
+ return -1;
+ return (bptr - target);
}
/**
}
/**
@@
-273,10
+277,12
@@
void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks)
void escputs1(char *strbuf, int nbsp, int nolinebreaks)
{
char *buf;
void escputs1(char *strbuf, int nbsp, int nolinebreaks)
{
char *buf;
+ long Siz;
if (strbuf == NULL) return;
if (strbuf == NULL) return;
- buf = malloc( (3 * strlen(strbuf)) + SIZ );
- stresc(buf, strbuf, nbsp, nolinebreaks);
+ Siz = (3 * strlen(strbuf)) + SIZ ;
+ buf = malloc(Siz);
+ stresc(buf, Siz, strbuf, nbsp, nolinebreaks);
wprintf("%s", buf);
free(buf);
}
wprintf("%s", buf);
free(buf);
}
@@
-412,7
+418,7
@@
void msgescputs1( char *strbuf)
outbuf = malloc( buflen);
outbuf2 = malloc( buflen);
msgesc(outbuf, strbuf);
outbuf = malloc( buflen);
outbuf2 = malloc( buflen);
msgesc(outbuf, strbuf);
- stresc(outbuf2, outbuf, 0, 0);
+ stresc(outbuf2,
buflen,
outbuf, 0, 0);
wprintf("%s", outbuf2);
free(outbuf);
free(outbuf2);
wprintf("%s", outbuf2);
free(outbuf);
free(outbuf2);