Project

General

Profile

Bug #4878

bug with printf and missing unsigned argument

Added by Garrett D'Amore over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Start date:
2014-05-22
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

The upstream/downstream FreeBSD fixed a problem with printf:

http://svnweb.freebsd.org/base?view=revision&revision=244407

We need to fix this (basically we never integrated that change), and add a test in the regression suite.

#1

Updated by Garrett D'Amore over 6 years ago

diff --git a/usr/src/cmd/printf/printf.c b/usr/src/cmd/printf/printf.c
index bf07982..c5948ff 100644
--- a/usr/src/cmd/printf/printf.c
+++ b/usr/src/cmd/printf/printf.c
@@ -558,7 +558,7 @@ getnum(intmax_t *ip, uintmax_t *uip, int signedconv)
     int rval;

     if (!*gargv) {
-        *ip = 0;
+        *ip = *uip = 0;
         return (0);
     }
     if (**gargv == '"' || **gargv == '\\'') {
diff --git a/usr/src/test/util-tests/tests/printf/printf_test.ksh b/usr/src/test/util-tests/tests/printf/printf_test.ksh
index 22bc5d6..da648e5 100644
--- a/usr/src/test/util-tests/tests/printf/printf_test.ksh
+++ b/usr/src/test/util-tests/tests/printf/printf_test.ksh
@@ -179,6 +179,18 @@ tests[21][format]='%2$s'
 tests[21][args]='abc xyz'
 tests[21][result]="xyz" 

+typeset -A tests[22]=()
+tests[22][desc]="verify missing signed arg" 
+tests[22][format]='%d %d'
+tests[22][args]='151'
+tests[22][result]="151 0" 
+
+typeset -A tests[23]=()
+tests[23][desc]="verify missing unsigned arg" 
+tests[23][format]='%u %u'
+tests[23][args]='151'
+tests[23][result]="151 0" 
+
 #debug=yes

 for i in "${!tests[@]}"; do

#2

Updated by Electric Monk over 6 years ago

  • Status changed from New to Closed
  • % Done changed from 90 to 100

git commit e56bd28502ece54c39ad86fd96643790902bb93e

commit  e56bd28502ece54c39ad86fd96643790902bb93e
Author: Garrett D'Amore <garrett@damore.org>
Date:   2014-04-29T13:32:39.000Z

    4878 bug with printf and missing unsigned argument
    Reviewed by: Andy Stormont <andyjstormont@gmail.com>
    Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
    Approved by: Dan McDonald <danmcd@omniti.com>

Also available in: Atom PDF