[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

varbufprintf is broken



According to the man page I have here vsnprintf() returns -1 on
overflow (and indeed this appears to be true).  This patch should cope
with that case.

It is not tested.  AFAICS this is the only place where
vsnprintf()/snprintf() are used in dpkg.

ttfn/rjk

Index: lib/varbuf.c
===================================================================
RCS file: /usr/src/CVS/dpkg/lib/varbuf.c,v
retrieving revision 1.1
diff -u -r1.1 varbuf.c
--- lib/varbuf.c        1998/10/25 22:25:24     1.1
+++ lib/varbuf.c        1999/08/15 14:03:22
@@ -42,6 +42,7 @@
     va_start(al,fmt);
     r= vsnprintf(v->buf+ou,v->size-ou,fmt,al);
     va_end(al);
+    if(r < 0) r = (v->size - ou + 1) * 2;
     v->used= ou+r;
   } while (r >= v->size-ou-1);
 }


Reply to: