changeset 22332:b1e71f6437ac

11924 infinite loop in mdb ::load Reviewed by: John Levon <john.levon@joyent.com> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Dan McDonald <danmcd@joyent.com>
author Mark Brooks <mark.brooks@joyent.com>
date Tue, 05 Nov 2019 11:30:38 +0000
parents 7906cb63dfce
children 6b6d176c3ef0
files usr/src/cmd/mdb/common/mdb/mdb_module_load.c
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/mdb/common/mdb/mdb_module_load.c	Wed Nov 06 23:12:34 2019 +0000
+++ b/usr/src/cmd/mdb/common/mdb/mdb_module_load.c	Tue Nov 05 11:30:38 2019 +0000
@@ -22,7 +22,7 @@
 /*
  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012 by Delphix. All rights reserved.
- * Copyright (c) 2012 Joyent, Inc. All rights reserved.
+ * Copyright 2019 Joyent, Inc.
  */
 
 #include <sys/param.h>
@@ -60,21 +60,22 @@
 		/*
 		 * Remove any .so(.[0-9]+)? suffix
 		 */
-		while ((p = strrchr(buf, '.')) != NULL) {
+		if ((p = strrchr(buf, '.')) != NULL) {
 			for (q = p + 1; isdigit(*q); q++)
 				;
 
 			if (*q == '\0') {
-				/* found digits to remove */
-				*p = '\0';
-				continue;
-			}
+				if (q > p + 1) {
 
-			if (strcmp(p, ".so") == 0) {
-				*p = '\0';
-				break;
+					/* found digits to remove */
+					*p = '\0';
+				}
 			}
-
+			if ((p = strrchr(buf, '.')) != NULL) {
+				if (strcmp(p, ".so") == 0) {
+					*p = '\0';
+				}
+			}
 		}
 		fullname = name;
 		name = buf;