X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/1d28cc061677bd07d9bed48dd84bd5c590247043..3f77bd134b64c532748b83c3931df07058268b5e:/src/src/dbfn.c diff --git a/src/src/dbfn.c b/src/src/dbfn.c index 3c51162a4..389d1518e 100644 --- a/src/src/dbfn.c +++ b/src/src/dbfn.c @@ -239,12 +239,13 @@ Returns: a pointer to the retrieved record, or */ void * -dbfn_read_with_length(open_db *dbblock, const uschar *key, int *length) +dbfn_read_with_length(open_db * dbblock, const uschar * key, int * length) { -void *yield; +void * yield; EXIM_DATUM key_datum, result_datum; int klen = Ustrlen(key) + 1; uschar * key_copy = store_get(klen, key); +unsigned dlen; memcpy(key_copy, key, klen); @@ -260,9 +261,10 @@ if (!exim_dbget(dbblock->dbptr, &key_datum, &result_datum)) return NULL; /* Assume the data store could have been tainted. Properly, we should store the taint status with the data. */ -yield = store_get(exim_datum_size_get(&result_datum), GET_TAINTED); -memcpy(yield, exim_datum_data_get(&result_datum), exim_datum_size_get(&result_datum)); -if (length) *length = exim_datum_size_get(&result_datum); +dlen = exim_datum_size_get(&result_datum); +yield = store_get(dlen, GET_TAINTED); +memcpy(yield, exim_datum_data_get(&result_datum), dlen); +if (length) *length = dlen; exim_datum_free(&result_datum); /* Some DBM libs require freeing */ return yield; @@ -488,7 +490,7 @@ while (Ufgets(buffer, 256, stdin) != NULL) { count = Uatoi(cmd); while (isdigit((uschar)*cmd)) cmd++; - while (isspace((uschar)*cmd)) cmd++; + Uskip_whitespace(&cmd); } if (Ustrncmp(cmd, "open", 4) == 0) @@ -496,7 +498,7 @@ while (Ufgets(buffer, 256, stdin) != NULL) int i; open_db *odb; uschar *s = cmd + 4; - while (isspace((uschar)*s)) s++; + Uskip_whitespace(&s); for (i = 0; i < max_db; i++) if (dbblock[i].dbptr == NULL) break; @@ -532,8 +534,7 @@ while (Ufgets(buffer, 256, stdin) != NULL) else if (Ustrncmp(cmd, "write", 5) == 0) { int rc = 0; - uschar *key = cmd + 5; - uschar *data; + uschar * key = cmd + 5, * data; if (current < 0) { @@ -541,11 +542,11 @@ while (Ufgets(buffer, 256, stdin) != NULL) continue; } - while (isspace((uschar)*key)) key++; + Uskip_whitespace(&key); data = key; - while (*data != 0 && !isspace((uschar)*data)) data++; - *data++ = 0; - while (isspace((uschar)*data)) data++; + Uskip_nonwhite(&data); + *data++ = '\0'; + Uskip_whitespace(&data); dbwait = (dbdata_wait *)(&structbuffer); Ustrcpy(dbwait->text, data); @@ -560,13 +561,13 @@ while (Ufgets(buffer, 256, stdin) != NULL) else if (Ustrncmp(cmd, "read", 4) == 0) { - uschar *key = cmd + 4; + uschar * key = cmd + 4; if (current < 0) { printf("No current database\n"); continue; } - while (isspace((uschar)*key)) key++; + Uskip_whitespace(&key); start = clock(); while (count-- > 0) dbwait = (dbdata_wait *)dbfn_read_with_length(dbblock+ current, key, NULL); @@ -576,13 +577,13 @@ while (Ufgets(buffer, 256, stdin) != NULL) else if (Ustrncmp(cmd, "delete", 6) == 0) { - uschar *key = cmd + 6; + uschar * key = cmd + 6; if (current < 0) { printf("No current database\n"); continue; } - while (isspace((uschar)*key)) key++; + Uskip_whitespace(&key); dbfn_delete(dbblock + current, key); } @@ -612,8 +613,8 @@ while (Ufgets(buffer, 256, stdin) != NULL) else if (Ustrncmp(cmd, "close", 5) == 0) { - uschar *s = cmd + 5; - while (isspace((uschar)*s)) s++; + uschar * s = cmd + 5; + Uskip_whitespace(&s); i = Uatoi(s); if (i >= max_db || dbblock[i].dbptr == NULL) printf("Not open\n"); else { @@ -627,8 +628,8 @@ while (Ufgets(buffer, 256, stdin) != NULL) else if (Ustrncmp(cmd, "file", 4) == 0) { - uschar *s = cmd + 4; - while (isspace((uschar)*s)) s++; + uschar * s = cmd + 4; + Uskip_whitespace(&s); i = Uatoi(s); if (i >= max_db || dbblock[i].dbptr == NULL) printf("Not open\n"); else current = i; @@ -680,3 +681,5 @@ return 0; #endif /* End of dbfn.c */ +/* vi: aw ai sw=2 +*/