From: tytso Date: Fri, 10 Dec 1993 13:47:36 +0000 (+0000) Subject: Fix allocation strategy in setup_ahst(); shouldn't be redefining the argv X-Git-Tag: release77~34 X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/ac56da7d3c827687c1cfcf3fa86052c3f7822570 Fix allocation strategy in setup_ahst(); shouldn't be redefining the argv vector with newly allocated memory! Also, don't try to get a new machine id unless this is an add_host query. Removed declaration for malloc, to support optional debugging malloc. --- diff --git a/server/qsetup.dc b/server/qsetup.dc index d23e8d44..450619fd 100644 --- a/server/qsetup.dc +++ b/server/qsetup.dc @@ -314,7 +314,6 @@ int setup_alis(q, argv, cl) EXEC SQL BEGIN DECLARE SECTION; int ngid; EXEC SQL END DECLARE SECTION; - char *malloc(); unsigned char *p; int idx; @@ -969,9 +968,9 @@ setup_ahst(q,argv,cl) value = htonl(value); } value = htonl(value); - argv[9+row] = strsave(inet_ntoa(value)); + strcpy(argv[9+row], inet_ntoa(value)); } else { - argv[9+row] = strsave("unassigned"); + strcpy(argv[9+row], "unassigned"); } /* status checking */ @@ -1016,13 +1015,20 @@ setup_ahst(q,argv,cl) return(MR_PERM); } + /* + * If this is an update_host query, we're done. + */ + if (row == 1) + return(MR_SUCCESS); + + /* + * For an add_host query, allocate and fill in a new machine id, + * and then insert the creator id. + */ if ((mr_errcode = prefetch_value(q,argv,cl)) != MR_SUCCESS) return(mr_errcode); - row = q->argc + q->vcnt + 1; - sprintf(buf, "%d",cl->client_id); - argv[row] = strsave(buf); - argv[row+1] = NULL; + sprintf(argv[q->argc + q->vcnt + 1], "%d",cl->client_id); return(MR_SUCCESS); }