Skip to content

Commit 348d445

Browse files
committed
oauth: increase grant size
1 parent 1495e4d commit 348d445

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

plugins/protocol_lws_auth_server/protocol_lws_auth_server.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,7 +2436,7 @@ callback_auth_server(struct lws *wsi, enum lws_callback_reasons reason,
24362436
int lacks_grant = 0;
24372437
char sname[128] = {0};
24382438
char user_email[128] = {0};
2439-
char grants[256] = {0};
2439+
char grants[2048] = {0};
24402440
char *gp = grants, *gend = grants + sizeof(grants);
24412441
char logs[LWS_SSO_MAX_COOKIE] = {0};
24422442
lws_get_urlarg_by_name_safe(wsi, "service_name=", sname, sizeof(sname));
@@ -3184,7 +3184,7 @@ callback_auth_server(struct lws *wsi, enum lws_callback_reasons reason,
31843184
{
31853185
char op[32] = {0};
31863186
int req_uid = -1;
3187-
char new_grants[512] = {0};
3187+
char new_grants[2048] = {0};
31883188

31893189
char *gp;
31903190
if ((gp = (char *)strstr((const char *)in, "\"op\":\""))) {
@@ -3200,7 +3200,7 @@ callback_auth_server(struct lws *wsi, enum lws_callback_reasons reason,
32003200
if ((gp = (char *)strstr((const char *)in, "\"grants\":\""))) {
32013201
gp += 10;
32023202
int i = 0;
3203-
while (*gp && *gp != '"' && i < 511)
3203+
while (*gp && *gp != '"' && i < (int)sizeof(new_grants) - 1)
32043204
new_grants[i++] = *gp++;
32053205
}
32063206

@@ -3311,7 +3311,17 @@ callback_auth_server(struct lws *wsi, enum lws_callback_reasons reason,
33113311
char *p2 = new_grants;
33123312
while (*p2) {
33133313
char *comma = (char *)strchr(p2, ',');
3314-
if (comma) *comma = '\0';
3314+
char *semi = (char *)strchr(p2, ';');
3315+
char *delim = NULL;
3316+
3317+
if (comma && semi)
3318+
delim = (comma < semi) ? comma : semi;
3319+
else if (comma)
3320+
delim = comma;
3321+
else
3322+
delim = semi;
3323+
3324+
if (delim) *delim = '\0';
33153325
char *colon = (char *)strchr(p2, ':');
33163326
if (colon) {
33173327
*colon = '\0';
@@ -3334,8 +3344,8 @@ callback_auth_server(struct lws *wsi, enum lws_callback_reasons reason,
33343344
}
33353345
}
33363346
}
3337-
if (!comma) break;
3338-
p2 = comma + 1;
3347+
if (!delim) break;
3348+
p2 = delim + 1;
33393349
}
33403350
sqlite3_exec(vhd->db, "COMMIT;", NULL, NULL, NULL);
33413351
}

0 commit comments

Comments
 (0)