The last commit to this file fixed two (void)asprintf calls. Fix the
two remaining calls: depend on the ret buffer being set to NULL on
failure.
ok?
Index: dump.c
===================================================================
RCS file: /d/cvs/src/usr.sbin/rtadvd/dump.c,v
retrieving revision 1.22
diff -u -p -p -u -r1.22 dump.c
--- dump.c 2 Apr 2017 22:57:20 -0000 1.22
+++ dump.c 4 Apr 2017 16:53:22 -0000
@@ -113,7 +113,7 @@ rtadvd_dump(void)
int first;
struct timeval now, next;
char *origin, *vltime, *pltime, *flags;
- char *vltimexpire=NULL, *pltimexpire=NULL;
+ char *vltimexpire, *pltimexpire;
char ctimebuf[26];
gettimeofday(&now, NULL);
@@ -186,16 +186,23 @@ rtadvd_dump(void)
default:
origin = "";
}
- if (pfx->vltimeexpire != 0)
+ if (pfx->vltimeexpire != 0) {
/* truncate to onwire value */
- asprintf(&vltimexpire, "(decr,expire %u)",
+ if (asprintf(&vltimexpire, "(decr,expire %u)",
(u_int32_t)(pfx->vltimeexpire > now.tv_sec ?
- pfx->vltimeexpire - now.tv_sec : 0));
- if (pfx->pltimeexpire != 0)
+ pfx->vltimeexpire - now.tv_sec : 0)) == -1)
+ vltimexpire = NULL;
+ } else
+ vltimexpire = NULL;
+
+ if (pfx->pltimeexpire != 0) {
/* truncate to onwire value */
- asprintf(&pltimexpire, "(decr,expire %u)",
+ if (asprintf(&pltimexpire, "(decr,expire %u)",
(u_int32_t)(pfx->pltimeexpire > now.tv_sec ?
- pfx->pltimeexpire - now.tv_sec : 0));
+ pfx->pltimeexpire - now.tv_sec : 0)) == -1)
+ pltimexpire = NULL;
+ } else
+ pltimexpire = NULL;
vltime = lifetime(pfx->validlifetime);
pltime = lifetime(pfx->preflifetime);
--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE