Skip to content
Snippets Groups Projects
Commit 8aa53b61 authored by rswindell's avatar rswindell
Browse files

Better handling of unsupported/unrecognized option names.

parent 8da04931
No related branches found
No related tags found
No related merge requests found
...@@ -849,7 +849,7 @@ js_getsockopt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval ...@@ -849,7 +849,7 @@ js_getsockopt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
opt = sockopt(JS_GetStringBytes(JS_ValueToString(cx,argv[0])),&level); opt = sockopt(JS_GetStringBytes(JS_ValueToString(cx,argv[0])),&level);
len = sizeof(val); len = sizeof(val);
if(getsockopt(p->sock, level, opt, (void*)&val, &len)==0) { if(opt!=-1 && getsockopt(p->sock, level, opt, (void*)&val, &len)==0) {
dbprintf(FALSE, p, "option %d = %d",opt,val); dbprintf(FALSE, p, "option %d = %d",opt,val);
JS_NewNumberValue(cx,val,rval); JS_NewNumberValue(cx,val,rval);
} else { } else {
......
...@@ -76,6 +76,8 @@ int DLLCALL sockopt(char* str, int* level) ...@@ -76,6 +76,8 @@ int DLLCALL sockopt(char* str, int* level)
return(option_names[i].value); return(option_names[i].value);
} }
} }
if(!isdigit(str[0])) /* unknown option name */
return(-1);
return(strtoul(str,NULL,0)); return(strtoul(str,NULL,0));
} }
...@@ -118,7 +120,8 @@ int DLLCALL set_socket_options(scfg_t* cfg, SOCKET sock, char* error) ...@@ -118,7 +120,8 @@ int DLLCALL set_socket_options(scfg_t* cfg, SOCKET sock, char* error)
p=name; p=name;
while(*p && *p>' ') p++; while(*p && *p>' ') p++;
if(*p) *(p++)=0; if(*p) *(p++)=0;
option=sockopt(name,&level); if((option=sockopt(name,&level))==-1)
continue;
while(*p && *p<=' ') p++; while(*p && *p<=' ') p++;
len=sizeof(value); len=sizeof(value);
value=strtol(p,NULL,0); value=strtol(p,NULL,0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment