]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: deviceatlas: check getproptype return and remove pprop indirection
authorDavid Carlier <dcarlier@deviceatlas.com>
Sat, 14 Feb 2026 13:24:04 +0000 (13:24 +0000)
committerWilly Tarreau <w@1wt.eu>
Sat, 14 Feb 2026 13:47:22 +0000 (14:47 +0100)
Check the return value of da_atlas_getproptype() and skip the property
on failure instead of using an uninitialized proptype. Also remove the
unnecessary pprop pointer indirection, using prop directly.

addons/deviceatlas/da.c

index 676d4222cccb5d614920008f13e813e5588d95a7..c5d5585212008fee770b6a222f78d07b59945a38 100644 (file)
@@ -324,7 +324,7 @@ static void da_haproxy_checkinst(void)
 static int da_haproxy(const struct arg *args, struct sample *smp, da_deviceinfo_t *devinfo)
 {
     struct buffer *tmp;
-    da_propid_t prop, *pprop;
+    da_propid_t prop;
     da_status_t status;
     da_type_t proptype;
        const char *propname;
@@ -344,13 +344,15 @@ static int da_haproxy(const struct arg *args, struct sample *smp, da_deviceinfo_
                        chunk_appendf(tmp, "%c", global_deviceatlas.separator);
                        continue;
                }
-               pprop = &prop;
-               da_atlas_getproptype(&global_deviceatlas.atlas, *pprop, &proptype);
+               if (unlikely(da_atlas_getproptype(&global_deviceatlas.atlas, prop, &proptype) != DA_OK)) {
+                       chunk_appendf(tmp, "%c", global_deviceatlas.separator);
+                       continue;
+               }
 
                switch (proptype) {
                        case DA_TYPE_BOOLEAN: {
                                bool val;
-                               status = da_getpropboolean(devinfo, *pprop, &val);
+                               status = da_getpropboolean(devinfo, prop, &val);
                                if (status == DA_OK) {
                                        chunk_appendf(tmp, "%d", val);
                                }
@@ -359,7 +361,7 @@ static int da_haproxy(const struct arg *args, struct sample *smp, da_deviceinfo_
                        case DA_TYPE_INTEGER:
                        case DA_TYPE_NUMBER: {
                                long val;
-                               status = da_getpropinteger(devinfo, *pprop, &val);
+                               status = da_getpropinteger(devinfo, prop, &val);
                                if (status == DA_OK) {
                                        chunk_appendf(tmp, "%ld", val);
                                }
@@ -367,7 +369,7 @@ static int da_haproxy(const struct arg *args, struct sample *smp, da_deviceinfo_
                        }
                        case DA_TYPE_STRING: {
                                const char *val;
-                               status = da_getpropstring(devinfo, *pprop, &val);
+                               status = da_getpropstring(devinfo, prop, &val);
                                if (status == DA_OK) {
                                        chunk_appendf(tmp, "%s", val);
                                }