fix uninitialized buffer access

Sun, 11 Jun 2023 21:30:11 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 11 Jun 2023 21:30:11 +0200
changeset 757
7ced4052e8ca
parent 756
ea0e059bae72
child 758
606519b4a867

fix uninitialized buffer access

libidav/utils.c file | annotate | diff | comparison | revisions
--- a/libidav/utils.c	Sun Jun 11 21:23:45 2023 +0200
+++ b/libidav/utils.c	Sun Jun 11 21:30:11 2023 +0200
@@ -459,7 +459,7 @@
                 cxstring seg = cx_strn(seg_ptr, seg_len);
                 if(!cx_strcmp(seg, CX_STR(".."))) {
                     for(int j=buf.pos;j>=0;j--) {
-                        char t = buf.space[j];
+                        char t = j < buf.pos ? buf.space[j] : 0;
                         if(IS_PATH_SEPARATOR(t) || j == 0) {
                             buf.pos = j;
                             buf.size = j;

mercurial