xymon

Check-in [2328238c24]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add fgets() wrapper to safely skip NULLs embedded in log files (From Franco Gasperino) git-svn-id: http://svn.code.sf.net/p/xymon/code/branches/4.3.19@7605 44351d6e-118b-4698-b696-ce33095ecaa4
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | origin/4.3.19
Files: files | file ages | folders
SHA3-256: 2328238c247043ab3c015cb9fb8727ef0f95459b2e26282562b6bab5f67e8633
User & Date: jccleaver@users.sf.net 2015-03-21 11:20:39
Context
2015-03-21
11:29
Add debug lines in logfetch.c; warn properly on invalid regexes git-svn-id: http://svn.code.sf.net/p/xymon/code/branches/4.3.19@7606 44351d6e-118b-4698-b696-ce33095ecaa4 check-in: 43b52d60d4 user: jccleaver@users.sf.net tags: trunk, origin/4.3.19
11:20
Add fgets() wrapper to safely skip NULLs embedded in log files (From Franco Gasperino) git-svn-id: http://svn.code.sf.net/p/xymon/code/branches/4.3.19@7605 44351d6e-118b-4698-b696-ce33095ecaa4 check-in: 2328238c24 user: jccleaver@users.sf.net tags: trunk, origin/4.3.19
10:22
logfetch: Ensure multiple triggerline blocks get sent in low maxbyte situations (From Franco Gasperino) git-svn-id: http://svn.code.sf.net/p/xymon/code/branches/4.3.19@7604 44351d6e-118b-4698-b696-ce33095ecaa4 check-in: 87c83232b4 user: jccleaver@users.sf.net tags: trunk, origin/4.3.19
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to client/logfetch.c.

98
99
100
101
102
103
104


























105
106
107
108
109
110
111
...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#ifdef BIG_SECURITY_HOLE
	drop_root();
#endif

	return fd;
}




























char *logdata(char *filename, logdef_t *logdef)
{
	static char *buf, *replacement = NULL;
	char *startpos, *fillpos, *triggerstartpos, *triggerendpos;
	FILE *fd;
	struct stat st;
................................................................................
	 * Read data.
	 * Discard the ignored lines as we go.
	 * Remember the last trigger line we see.
	 */
	fillpos = buf;
	bytesleft = bufsz;
	done = 0;
	while (!ferror(fd) && (bytesleft > 0) && !done && (fgets(fillpos, bytesleft, fd) != NULL)) {
		if (*fillpos == '\0') {
			/*
			 * fgets() can return an empty buffer without flagging
			 * end-of-file. It should not happen anymore now that
			 * we have extended the buffer to have room for the
			 * terminating \0 byte, but if it does then we will
			 * catch it here.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
...
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#ifdef BIG_SECURITY_HOLE
	drop_root();
#endif

	return fd;
}

/*
 * A wrapper for fgets() which eats embedded 0x00 characters in the stream.
 */
char *fgets_nonull(char *buf, size_t size, FILE *stream) {
	char *in, *out, *end;

	if (fgets(buf, size - 1, stream) == NULL) 
	        return NULL;

	end = memchr(buf, '\n', size - 1); 

	if (end == NULL) 
	        end = buf + (size - 1); 
	else 
	        end++;

	for (in = out = buf; in < end; in++) {
	        if (*in != '\0') 
		       *out++ = *in;
	}

	*out = '\0';

	return buf;
}


char *logdata(char *filename, logdef_t *logdef)
{
	static char *buf, *replacement = NULL;
	char *startpos, *fillpos, *triggerstartpos, *triggerendpos;
	FILE *fd;
	struct stat st;
................................................................................
	 * Read data.
	 * Discard the ignored lines as we go.
	 * Remember the last trigger line we see.
	 */
	fillpos = buf;
	bytesleft = bufsz;
	done = 0;
	while (!ferror(fd) && (bytesleft > 0) && !done && (fgets_nonull(fillpos, bytesleft, fd) != NULL)) {
		if (*fillpos == '\0') {
			/*
			 * fgets() can return an empty buffer without flagging
			 * end-of-file. It should not happen anymore now that
			 * we have extended the buffer to have room for the
			 * terminating \0 byte, but if it does then we will
			 * catch it here.