Skip to content

Commit

Permalink
No need to scan a whole string to see if the first char is null.
Browse files Browse the repository at this point in the history
Change-Id: I5eba2350e3c21ad8bde4194e6ef828bc8e1e5f25
Reviewed-on: http://review.northscale.com/2737
Reviewed-by: Chiyoung Seo <chiyoung.seo@gmail.com>
Tested-by: Chiyoung Seo <chiyoung.seo@gmail.com>
  • Loading branch information
dustin authored and chiyoung committed Sep 27, 2010
1 parent c3a74c6 commit d5b967e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bucket_engine.c
Expand Up @@ -350,7 +350,7 @@ static proxied_engine_handle_t* retain_handle(proxied_engine_handle_t *peh) {
}

static bool has_valid_bucket_name(const char *n) {
bool rv = strlen(n) > 0;
bool rv = n[0] != 0;
for (; *n; n++) {
rv &= isalpha(*n) || isdigit(*n) || *n == '.' || *n == '%' || *n == '_' || *n == '-';
}
Expand Down
6 changes: 6 additions & 0 deletions testapp.c
Expand Up @@ -780,6 +780,12 @@ static enum test_result test_bucket_name_validation(ENGINE_HANDLE *h,
assert(rv == ENGINE_SUCCESS);
assert(last_status == PROTOCOL_BINARY_RESPONSE_NOT_STORED);

pkt = create_create_bucket_pkt("", ENGINE_PATH, "");
rv = h1->unknown_command(h, mk_conn("admin", NULL), pkt, add_response);
free(pkt);
assert(rv == ENGINE_SUCCESS);
assert(last_status == PROTOCOL_BINARY_RESPONSE_NOT_STORED);

return SUCCESS;
}

Expand Down

0 comments on commit d5b967e

Please sign in to comment.