mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Fix extractLongLatOrReply() sanity check conditionals.
the check for lat/long valid ranges were performed inside the for loop, two times instead of one, and the first time when the second element of the array, xy[1], was yet not populated. This resulted into issue #2799. Close issue #2799.
This commit is contained in:
parent
3f38b51ad7
commit
f29e384853
@ -89,20 +89,20 @@ int decodeGeohash(double bits, double *xy) {
|
|||||||
/* Input Argument Helper */
|
/* Input Argument Helper */
|
||||||
/* Take a pointer to the latitude arg then use the next arg for longitude.
|
/* Take a pointer to the latitude arg then use the next arg for longitude.
|
||||||
* On parse error C_ERR is returned, otherwise C_OK. */
|
* On parse error C_ERR is returned, otherwise C_OK. */
|
||||||
int extractLongLatOrReply(client *c, robj **argv,
|
int extractLongLatOrReply(client *c, robj **argv, double *xy) {
|
||||||
double *xy) {
|
int i;
|
||||||
for (int i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
if (getDoubleFromObjectOrReply(c, argv[i], xy + i, NULL) !=
|
if (getDoubleFromObjectOrReply(c, argv[i], xy + i, NULL) !=
|
||||||
C_OK) {
|
C_OK) {
|
||||||
return C_ERR;
|
return C_ERR;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (xy[0] < GEO_LONG_MIN || xy[0] > GEO_LONG_MAX ||
|
if (xy[0] < GEO_LONG_MIN || xy[0] > GEO_LONG_MAX ||
|
||||||
xy[1] < GEO_LAT_MIN || xy[1] > GEO_LAT_MAX) {
|
xy[1] < GEO_LAT_MIN || xy[1] > GEO_LAT_MAX) {
|
||||||
addReplySds(c, sdscatprintf(sdsempty(),
|
addReplySds(c, sdscatprintf(sdsempty(),
|
||||||
"-ERR invalid longitude,latitude pair %f,%f\r\n",xy[0],xy[1]));
|
"-ERR invalid longitude,latitude pair %f,%f\r\n",xy[0],xy[1]));
|
||||||
return C_ERR;
|
return C_ERR;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return C_OK;
|
return C_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user