X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fvsprintf.c;h=0172902412613025213c07e7758af9492e2bd761;hb=5c34202b8bf942da411b6599668a76b07449bbfd;hp=b025864d2e43d08bffa10849610d5dce10b5b9ce;hpb=ef29498655b18d2bfd69048e20835d19333981ab;p=linux-2.6 diff --git a/lib/vsprintf.c b/lib/vsprintf.c index b025864d2e..0172902412 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -825,6 +825,17 @@ int vsscanf(const char * buf, const char * fmt, va_list args) break; str = next; } + + /* + * Now we've come all the way through so either the input string or the + * format ended. In the former case, there can be a %n at the current + * position in the format that needs to be filled. + */ + if (*fmt == '%' && *(fmt + 1) == 'n') { + int *p = (int *)va_arg(args, int *); + *p = str - buf; + } + return num; } @@ -851,23 +862,35 @@ EXPORT_SYMBOL(sscanf); /* Simplified asprintf. */ -char *kasprintf(gfp_t gfp, const char *fmt, ...) +char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap) { - va_list ap; unsigned int len; char *p; + va_list aq; - va_start(ap, fmt); - len = vsnprintf(NULL, 0, fmt, ap); - va_end(ap); + va_copy(aq, ap); + len = vsnprintf(NULL, 0, fmt, aq); + va_end(aq); p = kmalloc(len+1, gfp); if (!p) return NULL; - va_start(ap, fmt); + vsnprintf(p, len+1, fmt, ap); - va_end(ap); + return p; } +EXPORT_SYMBOL(kvasprintf); +char *kasprintf(gfp_t gfp, const char *fmt, ...) +{ + va_list ap; + char *p; + + va_start(ap, fmt); + p = kvasprintf(gfp, fmt, ap); + va_end(ap); + + return p; +} EXPORT_SYMBOL(kasprintf);