[hobbit] Hobbit 4.02 and Patches..

Henrik Stoerner henrik at hswn.dk
Wed Apr 20 14:58:53 CEST 2005


Hi Lars,

[the hobbit-enadis CGI hangs]

On Wed, Apr 20, 2005 at 09:24:59AM +0200, lars ebeling wrote:
> 
> (gdb) bt                                                                       
> #4  0xc01edc74 in fgets () from /usr/lib/libc.2                                
> #5  0x00003364 in parse_post () at hobbit-enadis.c:155                         
> #6  0x00003a04 in main (argc=2, argv=0x7f7e0578) at hobbit-enadis.c:231        

I don't know if it's just you or the HP-UX environment you're using,
but you have an annoying habit of spotting bugs that don't trigger
under the circumstances that I have. This bug is obvious, once I
actually read the CGI specification of how to handle POST requests.

Could you try the attached patch on top of the maintenance-feature-v2
patch and let me know if it solves the problem for you ?


Thanks,

Henrik
-------------- next part --------------
--- hobbitd/hobbit-enadis.c	2005/04/18 12:31:06	1.6
+++ hobbitd/hobbit-enadis.c	2005/04/20 12:45:17
@@ -50,13 +50,19 @@
 
 void parse_post(void)
 {
-	char l[4096];
+	char l[8192];
         char *token;
 	struct tm schedtm;
+	int lefttoread = atoi(xgetenv("CONTENT_LENGTH"));
 
 	memset(&schedtm, 0, sizeof(schedtm));
 
-	while (fgets(l, sizeof(l), stdin)) {
+	while (lefttoread > 0) {
+		if (fgets(l, sizeof(l), stdin) == NULL) {
+			errormsg("Error reading POST data\n");
+		}
+		lefttoread -= strlen(l);
+
 		l[sizeof(l)-1] = '\0';
 		token = strtok(l, "&");
 


More information about the Xymon mailing list