More strlcat/strlcpy truncate checks.
[amitay/samba.git] / source3 / libads / ads_struct.c
index b6c8e995ed452a477ce936b24b5b47ca917cfbe9..e6220fd320a38262499d237cda2017571ee4af6f 100644 (file)
@@ -52,10 +52,17 @@ char *ads_build_path(const char *realm, const char *sep, const char *field, int
                return NULL;
        }
 
-       strlcpy(ret,field, len);
+       if (strlcpy(ret,field, len) >= len) {
+               /* Truncate ! */
+               free(r);
+               return NULL;
+       }
        p=strtok_r(r, sep, &saveptr);
        if (p) {
-               strlcat(ret, p, len);
+               if (strlcat(ret, p, len) >= len) {
+                       free(r);
+                       return NULL;
+               }
 
                while ((p=strtok_r(NULL, sep, &saveptr)) != NULL) {
                        int retval;